Jquery 在转到选择列表中的URL之前,如何使用SimpleModel进行确认?

Jquery 在转到选择列表中的URL之前,如何使用SimpleModel进行确认?,jquery,url,select,simplemodal,confirm,Jquery,Url,Select,Simplemodal,Confirm,我有一张这样的表格: <select> <option value="page1.html" class="confirm">Page 1</option> <option value="page2.html" class="confirm">Page 2</option> <option value="page3.html">Page 3</option> </select>

我有一张这样的表格:

<select>
    <option value="page1.html" class="confirm">Page 1</option>
    <option value="page2.html" class="confirm">Page 2</option>
    <option value="page3.html">Page 3</option>
</select>

第1页
第2页
第3页

在转到第1页或第2页之前,我想使用SimpleModel显示确认信息,但如果选择了第3页,则不需要。第1页和第2页的确认信息应相同。我对如何执行语法有点困惑。

以中的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/';
        });
    }
});