简体   繁体   中英

How to stop the working of preventDefault() function

How to stop the preventDefault() function and what is opposite function of the preventDefault() function. How to enable the links after call of ajax stop function?

Simple don't use it!

If your link is :

<a href="www.google.com" id="myLink">link</a>

and your event is:

$('#myLink').click(function(){
console.log('no prevent')
//some code
return true:
});

after log you go to google...

You are using preventDefault() as

function(e){ e.preventDefault()};

and its opposite

function(e){ return true; }

Hope it will help you :)

Reference

There isn't an opposite to preventDefault() . The opposite to that would be 'do default' which, of course, is done, by default. You need to run a condition that will decide whether the default is prevented, before preventing it.

//Your hypothetical 'do default'
e.preventDefault()
if(condition){
    e.doDefault(); //METHOD DOES NOT EXIST!
}

//How you should do it
if(!condition){
    e.preventDefault();
}
return false; e.preventDefault(); 

both work same it prevents the process and stop the execution

and about your question there is one option return true; to continue the execution of function.

I hope it will help to solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM