Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the best way to call a javascript function on a link

I want to add some links to some website of mine, but these links will call a javascript function and will not be underlined, also I want the cursor to be changed to a standard pointer. Which is the best way of doing it and why?

Right now I can think of two aproaches:

<a href="javascript:someFunction()" style="text-decoration:none">LINK</a>

or

<span onClick="someFunction();" style="cursor: pointer;">LINK</span>

Which one do you think is better?

like image 913
oscarello Avatar asked Jan 21 '23 11:01

oscarello


1 Answers

Since this isn't really going to be a link (functionally or visually) you should stick with a <span> (or <div> if you want a block level element).

like image 130
Justin Niessner Avatar answered Feb 01 '23 20:02

Justin Niessner