Solved

jQuery: Combine Not into First Element Selector

Posted on 2013-05-22
1
427 Views
Last Modified: 2013-05-23
How can this be combined so that the "not" is combined with the first element selector?

$('a[href]').not('[href^="http"],[href^="mailto:"],[href^="/"],[href^="."],[href^="#"]').each(function(ev) { });

Open in new window

This does not work:

$('a[href]:not([href^="http"],[href^="mailto:"],[href^="/"],[href^="."],[href^="#"])').each(function(ev) {});

Open in new window

0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
mickey159 earned 500 total points
ID: 39189767
Additional Notes (from jqAPI)
The .not() method will end up providing you with more readable selections than pushing complex selectors or variables into a :not() selector filter. In most cases, it is a better choice.

I suppose it is better to separate using a .not() as you can read and maintain easily.
Please try this:

$('a:not([href^="http"],[href^="mailto:"],[href^="/"],[href^="."],[href^="#"])').each(function(ev) {});

Open in new window


Please give some more code so I can test the codes.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question