Home > Article > Web Front-end > A brief discussion on functions abandoned by jQuery and replacement functions_jquery
In the past, for better browser compatibility, jQuery-1.7.2 version has been used; however, with the rapid development of major browsers and technologies, even the new bootstrap version needs to introduce jQuery-1.9 or above. version, which means that the commonly used jQuery-1.7.2 should bid farewell to the stage of history;
But some of our commonly used functions have also been deprecated; if you don’t pay attention, various errors will be reported; let’s take a look at these abandoned functions; of course, if you don’t know these abandoned functions introduced; then congratulations! There is no need to remember it, you just need to understand its replacement function; the purpose of this article is to remind you which functions have been deprecated and which functions should be used to replace them; as for the specific use of the replacement function, please ask Gu Gedu Niang.
1: Deprecated function: .live()
Abandoned version: jQuery-1.9 or above
Alternative function: .on()
2: Deprecated function: .die()
Abandoned version: jQuery-1.9 or above
Alternative function: .off()
3: Deprecated function: .size()
Abandoned version: jQuery-1.8 or above
Alternative function: .length
4: Deprecated function: .toggle()
Abandoned version: jQuery-1.8 or above
Alternative function:. . . . . .
Fortunately, I left this function at the end when writing this article, because there is no official replacement function, but nothing can stop programmers with cleverness;
If it is used to switch css styles, you can use .toggleClass();
If you want to switch events; you can use the custom function below;
var i=0; $('#test').click(function(){ if(i==0){ //执行方法内容 i=1; }else{ //执行方法内容 i=0; } }
The above is the entire content of this article, I hope you all like it.