Use of getPreventDefault() is deprecated. Use defaultPrevented instead. Why I'm getting this error and what's the solution for it?

后端 未结 4 1558
忘了有多久
忘了有多久 2021-02-11 22:44

Previously I was using jQuery 1.7.1 in my code. I was getting the above error. Then I used the jQuery 1.11.1 straight from the google repository



        
4条回答
  •  逝去的感伤
    2021-02-11 23:00

    I have also come across this problem and found that with jQuery 1.x the replacement

    event.defaultPrevented;
    

    does not work at all, but the original

    event.getPreventDefault();
    

    still works as expected but does throw a warning on Firebug. I guess someone somewhere expects everyone to upgrade to jQuery 2.x eventually. This shouldn't be a fatal or critical error for you, simply a warning, and in this instance that the replacement feature doesn't work on jQuery 1.x then it's suitable to bare this in mind but not act upon this warning.

提交回复
热议问题