South3492
South3492

Reputation: 101

What is the correct way in HTML5 to use Javascript in anchors?

Simple question, what is the correct way in HTML5?

   1st: <a href="javascript:func('something')">Something</a>    
   2nd: <a href="javascript:void(0)" onclick="func('something')">Something</a>
   3rd: <a href="#" onclick="func('something')">Something</a><!-- probably bad approach -->
   4th: <a onclick="func('something')">Something</a>

I don't want to or can't use event listener because it is an EJS template and the 'something' are from serveride (NodeJS) variable.

Upvotes: 0

Views: 34

Answers (1)

South3492
South3492

Reputation: 101

I went with the first one. I have talked it about a web specialist he said there is no correct way but the most "liked" option is the event listener but since it is not an option for me because of the serverside ejs render i can choose any of them.

Upvotes: 1

Related Questions