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

jQuery determines which li is currently clicked_jquery

WBOY
Release: 2016-05-16 16:35:18
Original
1611 people have browsed it

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();
}
})
Copy after login
Related labels:
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