jQuery: running setInterval only when a given ID is present -


in jquery, execute code:

setinterval((function() {   return alert('hello'); }), 3000); 

but if dom contains element, such as

<div id="say_hello">say hello</div> 

this must basic, cannot seem right.

if( $( '#say_hello' ).length > 0 ) {   setinterval((function() {     return alert('hello');   }), 3000); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -