event.preventDefault() function not working in IE

后端 未结 11 2782
栀梦
栀梦 2020-11-22 02:22

Following is my JavaScript (mootools) code:

$(\'orderNowForm\').addEvent(\'submit\', function (event) {
    event.prev         


        
11条回答
  •  Happy的楠姐
    2020-11-22 03:01

    in IE, you can use

    event.returnValue = false;
    

    to achieve the same result.

    And in order not to get an error, you can test for the existence of preventDefault:

    if(event.preventDefault) event.preventDefault();
    

    You can combine the two with:

    event.preventDefault ? event.preventDefault() : (event.returnValue = false);
    

提交回复
热议问题