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
Post a Comment