JQUERY: Confirm Click with Custom PopUp Message

Miva Knowledge Base
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.
Important Notice: This information is for internal reference only. Use at your own risk.

JQUERY: Confirm Click with Custom PopUp Message

Scot Ranney • February 20, 2026


This is a slick little jquery bit that gives you a browser popup to confirm your click. Used on modules or in templates.

Includes a way to customize the message.

HTML

First, here's a basic link with a simple default "are you sure?" confirmation message:

<a class="confirmclick" href="something.html">Delete Everything!</a>

This will bring up "Are you sure?"

This link has a custom popup message:

<a class="confirmclick" data-msg="The frogs will be unhappy." href="something.html">Delete all lilly pads</a>

JQUERY

The jquery to handle this is short and simple. It either takes the message you put in data-msg or it defaults to "Are you sure?"

<script>
	$('.confirmclick').on('click', function () {
		var $el = $(this);
		var msg = $el.data('msg');
		if(!msg){
			msg = 'Are you sure?'
		}		
		return confirm(msg);
	});
</script>

https://www.scotsscripts.com/mvblog/jquery-confirm-click-with-custom-popup-message.html

mvkb_jquery