100+ jQuery Answers, first author in Quora to achieve this. · Author has 514 answers and 2.9M answer views · Updated 6y ·
If you want to have a click event on an element then simply add the click event for that element and forget the rest. In your case you have an anchor, just give your anchor some id and add the click event in jQuery like this:
- <a id="myAnc" href="#">Click Here</a>
- $("#myAnc").click(function() {
- alert("Your anchor is clicked.");
- });
So the above jQuery code will show alert box when the anchor is clicked.
Note: Check i have given “#” for href of anchor.
54K views ·
View upvotes
· View 1 share
· 1 of 6 answers
Something went wrong. Wait a moment and try again.