English 中文(简体)
• 如何利用ery子挑选没有 specific子的 d子
原标题:How to use jQuery to select divs that do not have tr tags with a specific id in them

Here s some sample code to explain what I m trying to do:

<div id="list_subpanel_contacts">
    <table>
        <tbody>
            <tr></tr>
            <tr class="oddListRowS1"></tr>
        </tbody>
    </table>
</div>
<div id="list_subpanel_accounts_usi_orders">
    <table>
        <tbody>
            <tr></tr>
        </tbody>
    </table>
</div>
<div id="list_subpanel_orders">
    <table>
        <tbody>
            <tr></tr>
            <tr class="oddListRowS1"></tr>
            <tr class="evenListRowS1"></tr>
        </tbody>
    </table>
</div>

我需要找到任何四舍五入的,从<>/strong>开始,“list_subpanel_”,和,有<tr>有一类“oddListRowS1”或“evenListRowS1”。

然后,我需要从四舍五入的第二次强调之后获得任何东西,并将之转至一项职能。

因此,在《法典》的例子中,“贱民”只能找到第二个干.,并将“账户_usi_orders”通过。

这远远超出了我目前对“贱民”选择的了解,因此,我不理解任何帮助。 感谢!

最佳回答

http://api.jquery.com/filter/“rel=“nofollow”

var divs = $("div[id^=list_subpanel_]").filter(function() {
    return !$(this).find("tr.oddListRowS1, tr.evenListRowS1").length;
});

为提取<条码>id 碎块,可使用:

divs.each(function() {
    yourFunction(this.id.substr(14));
});
问题回答
var elements = new Array();

var i = 0;

    $("div[id^= list_subpanel_ ]").each(function(){
        if($(this).find( tr.oddListRowS1,tr.evenListRowS1 ).attr("class") == undefined){
           elements[i] = $(this);
           i++;
        }
    });

    for(i = 0; i < elements.length; i++){
        $(elements[i]).attr("id","whatever");  //And then do what you want to do with it
    }




相关问题
Get element from selector given an index with jQuery

var items = $(".myClass"); The code above returns a number of items when used to select all elements. How can I select a specific element, for example the second one? Neither items(2) nor items[2] ...

jQuery Selector not working right

Okay, I cannot figure out what I m doing wrong here... Take the following jQuery selector... $( tr[batchid]:has(span.chkselb input:checked) span[id=assetcount] ) This returns 2 elements. Yet if I ...

jQuery select where attribute = value

I am trying to select an input where the value equals a dynamic value trimmed = jQuery.trim(a); preSelectedCheckBox = $(this).find("input[value=" + trimmed + "]"); The element exists but I ...

help with onseek and selectors

I am using this: $(function() { // initialize scrollable window.api = $("div.scrollable").scrollable({ clickable: true, activeClass: "active",...

Object-Oriented jQuery Question

$("#e1").click(function() { $("#descriptions div").removeClass("show"); $("#e1d").addClass("show"); }); $("#e2").click(function() { $("#descriptions div").removeClass("show"); $("#e2d")....