Home >Web Front-end >JS Tutorial >jQuery each terminates or skips example code_jquery

jQuery each terminates or skips example code_jquery

WBOY
WBOYOriginal
2016-05-16 17:09:271190browse

When iteration is involved, abnormal termination or forced skipping is inevitable. In jQuery's each function, there is the following relationship:
continue :return true;
break :return false;
Direct return will also jump out of jQuery.

Set the drop-down list to select and terminate the iteration

Copy the code The code is as follows:

$("#area option").each(function(){
if($(this).text()==addrTmp[2]){
$(this).attr("selected ", "selected");//
return false;
}
});
Statement:
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