如何找到没有使用jquery特定类的锚? [英] How to find anchor without a specifc class using jquery?

查看:111
本文介绍了如何找到没有使用jquery特定类的锚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从包含tab的某些特定div中删除带有href包含#tab而没有特定css类atitleTabs的锚。

$ $ $(window).load(function(){

$('div ul li a')。filter(function(){
if(!$('div ul li a')。hasClass('atitleTabs')){
alert('没有particlauar类的Got锚');
alert($('ul ul a a')。attr('href'));
} else {
alert ('用类'获取锚点);
}

});

});

我该怎么做,请帮助我,我如何达到目标。

解决方案

尝试使用 属性包含选择器 来实现你想要的,

  $('div [id * =tab] a [href * =#tab]:not(。atitleTabs)')。 

或者只是尝试与 .filter()

$ $ $ $ $('div [id * =tab] a [href * =#tab])' ).filter( ':否( atitleTabs。)')除去();


I want to remove anchors with href contains "#tab" without a specific css class "atitleTabs" from some specific divs whose Id contains "tab". I have tried the following code it didn't work for me.

$(window).load(function () {

    $('div ul li a').filter(function () {
        if (!$('div ul li a').hasClass('atitleTabs')) {
            alert('Got Anchor without the particlauar class');
            alert($('div ul li a').attr('href'));
        } else {
            alert('Got Anchor with class');
        }

    });

});

How can i do it, please help me, how can i achieve my goal.

解决方案

Try to use attribute contains selector to achieve what you want,

$('div[id*="tab"] a[href*="#tab"]:not(".atitleTabs")').remove();

or just try the samething with .filter()

$('div[id*="tab"] a[href*="#tab"])').filter(':not(".atitleTabs")').remove();

这篇关于如何找到没有使用jquery特定类的锚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆