Discussion on the function abandoned by jQuery and its substitution function
- 2020-06-03 05:52:34
- OfStack
Earlier, es1EN-1.7.2 was used for better browser compatibility. But with the rapid development of browsers and technologies, even the new version of bootstrap needs to introduce the version of jQuery-1.9 or above, which means that the commonly used ES4en-1.7.2 should leave the stage of history.
But some of the functions that we use a lot have been dropped; Do not pay attention to the words will be all kinds of error; Let's take a look at some of these discarded functions; And of course if you don't know these abandoned functions that are introduced; So you don't have to memorize it, you just have to understand the substitution; The point of this article is to remind dear friends which functions are deprecated and which should be replaced; As for the specific use of the replacement function please Google Baidu bar.
1: Deprecated function:.live ()
Abandoned version: jQuery-1.9 or above
Substitution function:.on ()
2: Deprecated function:.die ()
Abandoned version: jQuery-1.9 or above
Substitution function:.off ()
3: Deprecated function:.size ()
Abandoned version: jQuery-1.8 or above
Substitute function:.length
4: Deprecated function:.toggle ()
Abandoned version: jQuery-1.8 or above
Substitute function:...
It's a good idea to leave this function at the end of this article, because there's no official replacement, but nothing can stop a smart programmer;
If you are toggling the css style, use.toggleClass ();
If you want to switch events; You can use the following custom functions;
var i=0;
$('#test').click(function(){
if(i==0){
// Execute method content
i=1;
}else{
// Execute method content
i=0;
}
}
This is the end of this article, I hope you enjoy it.