Home >Web Front-end >JS Tutorial >jQuery determines which li is currently clicked_jquery

jQuery determines which li is currently clicked_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:35:181639browse

Use $(this).index() to get the subscript of li. The following is an example of style replacement:

$("#aa li").click(function(){
$("#aa li").removeClass("class名字,多个class用空格分开");
$(this).addClass("class名字,多个class用空格分开");
if($(this).index()!=0){
$("#submenu").hide();
}else{
$("#submenu").show();
}
})
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