Can I concatenate two strings in HTML?
I want to achieve the following functionality-
<a href="#"+"javascript:document.getElementsByTagName('div')[0].id">go to the 1st DIV tag.</a>
It could have been done using document.write()
in javascript but I want to know if there is any concatenation functionality in HTML itself.
No, there isn't. HTML is markup, it is not turing complete.
One (primitive) way to achieve this with JavaScript would be
<a href="#"
onclick="window.location.hash='#'+document.getElementsByTagName('div')[0].id; return false;">
go to the 1st DIV tag.
</a>
But since those links are useless when JS is not available, they should probably only be generated by JS in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With