Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate Two strings in HTML in client side(No Server)

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.

like image 608
Rajesh Paul Avatar asked Sep 16 '13 12:09

Rajesh Paul


2 Answers

No, there isn't. HTML is markup, it is not turing complete.

like image 143
simonzack Avatar answered Oct 26 '22 16:10

simonzack


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.

like image 36
CBroe Avatar answered Oct 26 '22 16:10

CBroe