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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -