Javascript: how to check if a text exists in a web page -
let's string "done successfuly" displayed somewhere in webpage , there way know if string exist using javascript ? thanks.
more details help. there may better ways. best given information you've provided:
if ( ( document.documentelement.textcontent || document.documentelement.innertext ).indexof('done successfuly') > -1 ) { // something... }
if know id or class-name or can otherwise select element directly contains text (e.g. h1#someheading span ...
) should more performant , cleaner approach.
edit worth noting: approach pick text within script , style tags too, not want. both textcontent
, innertext
have various quirks across browsers too. see more info.
Comments
Post a Comment