Jquery-獲取勾選的checkbox的同級節點數量


    // 獲取勾選的標簽值得上一個兄弟節點
            var groups = [];
            $('input[name="group_name"]:checked').siblings(".lable").each(function(){ 
                groups.push($(this).contents()); }); 
            // 將Groups的長度賦值給隱藏域
            $("#groupsCount").val(groups.length);
<c:forEach items="${lableGroupList}" var="var" varStatus="vs">
<div>
                                            <label class="lable"
                                                style="line-height: 30px;margin:0 15px;">
                                                ${var.group_name}:</label>
                                            <c:forEach items="${lableList}" var="lable" varStatus="vs">
                                                <c:choose>
                                                    <c:when
                                                        test="${lable.itemcat_group_id == var.itemcat_group_id}">
                                                         <input name="group_name"
                                                            value="${lable.itemcat_id}" type="checkbox" />    
                                                     ${lable.itemcat_name}
                                                    
                                               </c:when>
                                                </c:choose>
                                            </c:forEach>
    </div>
                                        </c:forEach>
        <input type="hidden" id="groupsCount" name="groupsCount">

 

$('#id').siblings(" 指定兄弟節點的id")   當前元素所有的兄弟節點
$('#id').prev(" 指定兄弟節點的id") 當前元素前一個兄弟節點
$('#id').prevaAll(" 指定兄弟節點的id") 當前元素之前所有的兄弟節點
$('#id').next(" 指定兄弟節點的id") 當前元素之后第一個兄弟節點
$('#id').nextAll(" 指定兄弟節點的id") 當前元素之后所有的兄弟節點


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM