[Solved] how can i convert this jquery to javascript


In Jquery contains gives you a string of text to look for.

So here you need to get all the h2 tag and search in their text.

As h2 elements don’t have a value, you should use innerHTML and then instead of contains, you should use includes method.

var allHTwos= document.getElementsByTagName('h2');
for (i=0; i<allHTwos.length; i++) {
    var gh = allHTwos[i];
    var ts = gh.innerHTML;
    if(ts.includes(search)){
// Do your hide/unhide here
}
}

solved how can i convert this jquery to javascript