There was a need to find elements by the code of the elements themselves, for example -
<a><img src="/bitrix/templates/mobile/images/google-play-img.png" alt="">test</a> Could not find anything like that.
There was a need to find elements by the code of the elements themselves, for example -
<a><img src="/bitrix/templates/mobile/images/google-play-img.png" alt="">test</a> Could not find anything like that.
The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .
Well, it's easy. You first need to parse the string. So you will get a list of nodes and their parameters. And you will have to go over all elements of the document and compare the correspondence of parameters and descendants.
Parsing can be replaced by the creation of an element with this html structure. And compare all the nodes of the document with the nodes of this element.
You can do so.
We are looking for the first tag in the search bar, in the example above it is a .
Further through document.getElementsByTagName we take all tags a from the document, and we compare with a search line through outerHTML.
Updated:
First we insert the search text into the page (somewhere in a hidden place, after the search is unforgettable, we delete the element) and take outerHTML from it, and then we do what I wrote above.
Why is this necessary? The fact is that the browser stores the page in its format, and if you have an extra space, for example, or a line break, the algorithm above will not work. Even if there are two spaces in the source file, there will be one space inside the browser. Therefore, this action we bring the line to the browser view, if there is a need for it.
<br/> he converts to <br> - Dmitry PolyaninSource: https://ru.stackoverflow.com/questions/778338/
All Articles
srcproperty is/bitrix/templates/mobile/images/google-play-img.png- torokhkun