user8598
1#
user8598 Published in September 20, 2018, 12:43 pm

I have a website where there is the same hyperlink(URL) shown on multiple pages and different locations. How can I set the hyperlink to a variable, store that variable somewhere then when I need to change the URL all I need to do is update the variable resulting in all hyperlinks pointing to that variable updating as well. rather than manually changing the hyperlink on every location on the site?

Hope this makes sense,

please post answers using the following methods 1- HTML 2- JavaScript 3-JQuery 4- (something I forgot to add to list but is easy to implement)

• Don't know if it is possible to do in a pure HTML. Instead, you can use JQuery in such way. Assume you have a <div id="element">: var hyperLink = '<a href="http://google.com'>Google</a>"; var element = \$('#element'); element.append(hyperLink);. – Alex Zakruzhetskyi Feb 12 at 15:46
• append? that would replace the var hyperlink to the var element? I am not a web developer but got stuck with this task :\ – NULL.Dude Feb 12 at 15:50
• It will add a hyperlink to the div – Alex Zakruzhetskyi Feb 12 at 15:50
• staticgen.com – Quentin Feb 12 at 15:51