One line code to show delete confirm box on link click

It’s always a good practice to alert users before changing something major.

Below is a line code to bring up a confirm box on click of a link.


Normal link: 

<a href="somelink">Delete</a>


Link with confirm box:

<a href="somelink" onclick="return confirm('Are you sure?')">Delete</a>


That’s all guys!

If you want a better user experience try using jQuery UI confirm box.

Please don’t forget to comment below… :) Thanks!