javascript - How to bind jquery function to specified element -


i want make function working on page specified element. have search page, search fields , results in search-block div. want bind function block, function not work on other pages (without <div id='search-block>...</div>)

i have next js code atm:

$(document).ready(function()     // instructions page (handlers links)      $(function(){         setinterval(findsomething,1000);     });      }); 

it working fine on page search-block div, works fine on other pages too. browser tries run function on other pages. don't need this.

i tried jquery bind, worked me, don't know why :(

$("#search-block").bind(function(){     setinterval(findsomething,1000); });  

how can bind handler speciges too.fied block?

instead of bind have check length of elem:

$(document).ready(function(){    if($('#search-block').length > 0){ // <---checks availability        setinterval(findsomething,1000);    } });  

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -