簡體   English   中英

遍歷jQuery中的匹配元素

[英]Loop through matching elements in jQuery

我有一個包含面板的中繼器控件。 我想遍歷轉發器中的面板,並使用jQuery根據輸入參數隱藏它們。

function ShowInfo(ctrlShow) {    
            jQuery("div[id*='_pnlInfo_']").each(function (index, value) {
               if(jQuery(this).attr('id').toLower() != ctrlShow.toLower())
                    jQuery(this).hide();
            });
            jQuery(ctrlShow).slideToggle(800);
        }

但這會引發錯誤:

Uncaught TypeError: undefined is not a function.

誰能建議該怎么做? 謝謝。

通過這樣從選擇器中排除特定元素,您可以使用另一種方法:

function showInfo(ctrlShow){
    $("div[id*='_pnlInfo_']").not("#" + ctrlShow).hide();
    $("#" + ctrlShow).slideToggle(800);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM