获取处于选中状态的多选框的索引值

HTML

 <div class="main">
    <input name="" type="checkbox" value="" checked="checked" />
    <input name="" type="checkbox" value="" checked="checked" />
    <input name="" type="checkbox" value="" />
    <input name="" type="checkbox" value="" />
    <input name="" type="checkbox" value="" />
</div> 

 

CSS

body { cursor:default; -webkit-text-size-adjust:none; font-size:13px; background:#FFF; line-height:50px; }
.clear { zoom:1; }
.clear:after { visibility:hidden; display:block; font-size:0; content:"1"; clear:both; height:0; }
.main { width:830px; margin:0 auto; }

 

JS

$(function(){
    var inputleng=$(".main input:checked").length;
    for(var i=0;i<$(".main input").length;i++){
        if($(".main input").eq(i).attr("checked")=="checked")
        {
            console.log(i);
        }
    }
    
})

 

截图

posted @ 2013-01-27 16:03  阿朱妹纸  阅读(483)  评论(0编辑  收藏  举报