Hi and thanks for your answer !

I'm trying to work with the node that contains the text e.g. "John".
But it could be any web page on which I want to select some text and
get the corresponding dom element (node).

My basic approach was to traverse through ALL dom nodes and look if
any of them contains the text that has been selected. If so, return
the node.

Thats why I tried this code: var array =  $("*:contains('SELECTED TEXT
ON THE WEB PAGE')");


Do you understand what I'm trying to do ?

Thanks, Alexander

On 30 Jun., 20:13, Charlie <charlie...@gmail.com> wrote:
> not sure you've explained what it is you are trying to do
> are you trying to work with "John" and create a selector/method to do it?
> Alexander wrote:Hi there ! I'm stuck with a problem and hope someone can give 
> me the right hint. I am trying to detect the DOM element on a unkown web page 
> from the current selected text on that page. Which means: I select text on a 
> web page and then I would like to get the dom element to which this text 
> belongs. What I came up with was something like that: (imagin we selected the 
> word John on that page....) var array = $("*:contains('John')"); ---> get all 
> dom elements that contain the text 'John' But, instead of returning all dom 
> elements that contain 'John' , it returns only the path from the HTML element 
> to the P element that contains the text 'John'. (HTML->Body->P) Did I miss 
> something ? Is there a complete different way to accomplish what I want ? 
> Thanks and good bye, Alexander

Reply via email to