Home > Article > Web Front-end > jQuery determines which li is currently clicked_jquery
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(); } })