user219200
user219200

Reputation: 105

How do I search Firefox code inspector for tags and exclude simple text results?

How can I find all the instances of a specific tag in the Firefox code inspector? E.g. if I want to find all instances of <th> , how can I search for this without being given every instance of 'th' in the text of the source code? No id="thread2", no <p> FEATHERS</p>, ideally not even instances of <thead>, just the <th> tags?

Whenever I type <th> in any queries into the search bar I get no results, as there is no non-tag text that has those characters in that sequence. I suspect there's some method to search for tags specifically that I don't know of but I have not been able to find it.

Upvotes: 3

Views: 1051

Answers (1)

Infineight
Infineight

Reputation: 558

On the DOM Inspector FAQ the solution for this is said to be, use a Regular Expression. In your case it would be ^th$. This did not work for me using Firefox 70.0.1.

The Firefox DOM Inspector search box uses CSS selectors as well, so I would like to tell you the answer is to "just do :is(th)", but support for that and the to-be outdated :matches pseudo-class do not seem to be there in the inspector search. Hopefully this will be the solution in the future.

The only solution I could come up with was to use the :not pseudo-class with something that actually does not exist. So as an example, th:not([_]).[] in CSS selectors looks for elements with the attribute inside the square brackets. So the example is searching for th tags that do not have the attribute _. There may be a more efficient pseudo-class to use than :not, but that's the only one I could find that works.

An alternate solution is to go the console and use document.querySelectorAll('th'). The output in the console will list all th tags in the DOM and give you an inspector link, that when clicked, brings you into the DOM inspector for that node.

Upvotes: 6

Related Questions