exclude a class from jquery for each

后端 未结 4 1327
情话喂你
情话喂你 2021-01-15 01:59

My code is like this

$(\"a[href]\").each(function () {
    if ($(this).attr(\"href\").toLowerCase().indexOf(\"javascript:\") != 0 &&     $(this).attr         


        
相关标签:
4条回答
  • 2021-01-15 02:23

    You can user jquery not selector. http://api.jquery.com/not-selector/

    0 讨论(0)
  • 2021-01-15 02:27

    Use filter():

    $('a[href]').filter(function(){
        return !$(this).hasClass('tax-switch');
    }).each(function(){
        // do your stuff
    });
    

    References:

    • filter().
    0 讨论(0)
  • 2021-01-15 02:34

    As @vivek has said, use the not function:

    $('a[href]').not('.tax-switch').each(
    

    This'll select all anchors that do not have the class 'tax-switch'.

    0 讨论(0)
  • 2021-01-15 02:44

    try this code , Working fiddle

    $("a[href]:not(.tax-switch)").each(function () {
       $("#myDIV").append('<p>'+ $(this).html()+'</p>');
    });
    
    0 讨论(0)
提交回复
热议问题