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 which are not in a link ( tags).
My Sample HTML part
<div> <p>... some text ....
....................................
<strong>......keyword......</strong>
....................................
...........................keyword..
....................................
</p> </div>
I used ":contains" selector to search this keyword in JS and used document body as search context. After search results I will replace the elements with some link(keyword).
Sizzle(":contains(keyword)", document.body);
It returns me an array contains "div, p, strong" elements. There is 2 "keyword" s in the context both it returns parent elements of results (div is unnecessary here).
Is there any usage of Sizzle to prevent this problem?
An extra question: I searched Sizzle selectros, also w3c selectors. ":not" selector is used to get negative given selector. How can I see the element is not in a link tag without traversing dom with "parentElement" attribute(I mean with sizzle selectors considering the link tag can be upper parent nodes of element).
Thanks.