I am trying to count the number of opening <tr
s and compare them to the number of closing /tr>
s to check for template errors in my HTML generation. My code is pretty simple:
var markup = document.documentElement.innerHTML; //to have it as a string
var trstart_results = (markup.match(/<tr/g) || []).length;
var trend_results = (markup.match(/\/tr>/g) || []).length;
Problem is, that I have in HTML code 95x tr
and 97x /tr
, but console.log says both are 97x.
Anyone know, what is wrong with this code?