I have a small piece of javascript to get a user to confirm things on my website. I have a link that I also ask them to confirm before proceeding. I’ve used the ‘onclick’ function with buttons no problem, but how do I use it on a link?
Heres my link:
echo"<a href=\"$urlHTML\">Delete</a>";
And heres my ‘onclick’:
onclick="return confirm('Please confirm you wish to edit these details')"/>
Any help would be great!
You can use onclick on an anchor tag the same way you’d use it on a button:
However you’d be better off using an event handler:
I recommend you also read up on jQuery. It’ll save you a lot of time.