Skip to content
Advertisement

selecting element based on innertext javascript

JavaScript

I am trying to search this DOM. My search criteria is innerText, which is “div-1”. If that innerText is found, then I want to return the value as “div-1-span-1-div” and “div-1-span-1-span” which are again the innerText. How to achieve this using Javascript.

Advertisement

Answer

While I’m unsure of the logic behind the requirements I believe the following code seems to do what you ask:

JavaScript
JavaScript
JavaScript

References:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement