The Web Blinders logo

Programming

HTML - How to attach onclick event to Anchor tag (a)

LIVE DEMO : Click this link for live demo

This is how you do it

<a href="javascript:void();" onclick="yourFunction();">Click me</a>
function yourFunction(){
 // your code
 window.alert("It works");
} 

ALTERNATE TITLES

javascript a tag onclick prevent default

how to add onclick to anchor tag javascript

Need developers ?

if so, send a message.

thewebblinders@gmail.com

More Programming from our blog

SEARCH FOR ARTICLES