Monday 17 October 2016

firefox - Search for the exact child node with HTML using javascript

getElementsByTagName("*") will get you the child nodes in Depth First Search in Pre-order. The problem is if I search for a string inside the node's HTML, there is no way to tell the same is inside another child node that is going to be returned by the getElementsByTagName("*"). So, is there any way to iterate nodes from leaves to root?
Most probably a DFS-Post order will do the trick!



For example:



  



textmore text






If we are searching for more text, then innerHTML of first element for the result as well as all the subsequent elements will match. But I want only the exact child to match the string. If we are starting from the leaves, then we can break away after finding the text.



Any other idea?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...