以SimpleModal Confirm Demo中的 JavaScript 为例,您可以执行以下操作:
// replace 'form' with your form selector
$('form').submit(function (e) {
// replace 'option:selected' with a more specific selector
var opt = $('option:selected');
// if the selected option has a class of confirm, show the dialog
if (opt.hasClass('confirm')) {
e.preventDefault();
// example of calling the confirm function
// you must use a callback function to perform the "yes" action
confirm("Continue to the SimpleModal Project page?", function () {
window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
});
}
});