$(function(){
var len = $("#ul li").length;
var hide = 4;
$("ul li").each(function(index){
if ( index > hide ){
$(this).hide();//第(hide+1)几个以后开始隐藏
};
$(this).click(function(){
if(index
}
});
});
});
用jquery的话这样隐藏所有大于5的li:
$('ul li').each( index ){
if ( index > 4 ){
$(this).hide()
}
}
$("li").each(function(index){
$(this).click(function(){
if(index==0){
//代码块
}else if(index==1){
//代码块
}
})
})