jQuery选择器问题.选择所有不以(字符串)开头的节点 [英] jQuery selector question. Select all nodes that do NOT START with (string)

查看:77
本文介绍了jQuery选择器问题.选择所有不以(字符串)开头的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在此处组装一个相当复杂的jQuery选择器,但遇到了麻烦.

Trying to assemble a rather complex jQuery selector here, and having trouble.

从本质上讲,我试图获取以下所有锚点:1)没有"facebox"的"rel", OR 2)没有以"mailto"开头的"href".

Essentially, I'm trying to grab all anchors that that 1) do not have a "rel" of "facebox", and OR 2) do not have an "href" that begins with "mailto".

这就是我一直在尝试的事情:

This is what I've been trying to do:

$('a[rel!=facebox], a[href!^="mailto"]')

这种小的变化似乎不起作用.有解决这个问题的更好方法吗?

Small variations of this don't seem to work. Is there some better way of going about this?

这些选择器似乎可以单独工作,但是当连续坐在同一个选择器中时却不能工作:

These selectors seem to work individually, but not when sitting consecutively in the same selector:

$('a:not([rel=facebox]), a:not([href^=mailto])')

最终解决方案:我们有赢家!

$('a:not([rel=facebox],[href^=mailto])')

推荐答案

您需要:not选择器

$("a:not([rel=facebox],[href^=mailto])");

为了您的正确性,我偷了你的答案

I stole your answer for correctness

这篇关于jQuery选择器问题.选择所有不以(字符串)开头的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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