I know my question might look like a duplication for this question, but its not
I am trying to match a class name inside html text that comes from the
Use the browser to your advantage:
var str = '\
\
\
';
var wrapper = document.createElement('div');
wrapper.innerHTML = str;
var elements = wrapper.getElementsByClassName('b');
if (elements.length) {
// there are elements with class b
}
Demo
Btw, getElementsByClassName()
is not very well supported in IE until version 9; check this answer for an alternative.