This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How can I select elements of body which are not children of a link tag with Sizzle/Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How can I select elements of body which are not children of a link tag with Sizzle/Javascript" Watch "How can I select elements of body which are not children of a link tag with Sizzle/Javascript" New topic
Author

How can I select elements of body which are not children of a link tag with Sizzle/Javascript

sinan goker
Greenhorn

Joined: Apr 21, 2012
Posts: 1
I am newbie in both JS and Sizzle, trying to implement a system
that generates links according to a keyword like Google AdSense do.
I ve searched and decided to use Sizzle CSS Selector for this.

I have an html document and a keyword, I want to search all keywords in
the document body which are not in a link(a, area, etc.) tag.

Sample content



Selector code and replace operation


After changing keywords with links, the output content is



It changes all keywords in the document. The second keyword would not be changed according to my system. Because it has 2 "a" tags like <a><a></a></a>
I need a selector to select elements which are not childen of any link tags.

Any idea?
Thanks.






Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You probably want to use the not selector.

Eric
 
jQuery in Action, 2nd edition
 
subject: How can I select elements of body which are not children of a link tag with Sizzle/Javascript