I have some HTML DOM elements for which I need to capture click events, like a drop-down menu widget, etc. I guess we can implement in 2 ways:
<a href="javascript:void(0);" id="option1">My text</a> or another way is:
<span id="option2">My text 2</span> In the second option, of course I can add CSS property cursor:pointercursor:pointer.
All I need is to capture the click event, for which I can have the same click handler function for both the cases.
Do you think there is any reason why we would use anchor tag method ?
The second option looks more clean. Also, the IE has a default behavior for anchor tag click events, which can have unwanted consequences, etc.