Home > Web Front-end > JS Tutorial > body text

A brief discussion on functions abandoned by jQuery and replacement functions_jquery

WBOY
Release: 2016-05-16 16:01:25
Original
1510 people have browsed it

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;
}
}
Copy after login

The above is the entire content of this article, I hope you all like it.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!