Question one:
Since jquery can dynamically add page elements asynchronously, many times we don't know when a page element is loaded. The regular jquery of ready and JS Document.onload execution is perhaps the element we need to manipulate has not been built yet. So we can only use the timer to constantly loop, judging if the element generated. Then do the actions we want.
1 //page load completion is performed2$(function () {3 Customtimer ();4 });5 //Custom Timers (assuming Div_digg is dynamically generated)6 functionCustomtimer () {7 if($ ("#div_digg"). length) {8 //$ ("#div_digg"). Here you can do the action you want9 }Ten Else { One varIntervalid = SetInterval (function () { A if($ ("#div_digg"). Length) {//loop to determine if there is -Clearinterval (Intervalid);//then turn off the timer -Customtimer ();//Execute itself the } -}, 100); - } -}
JS Problem notes