Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect to see if a Div exists

Status
Not open for further replies.

booeyOH

Programmer
May 30, 2007
48
US
Hello,
I am doing some programming with xajax type stuff, and I have a problem that keeps creeping up on me.

I have a function that runs at a certain point in the script (testfunction()), and it references a div (testdiv). It doesn't work sometimes because the the function runs before the div "exists". Is there a way to check to see if a div exists so I can loop inside the function to wait until the div exists?

Such as:

function testfunction()
{
while(!exists('testdiv'))
wait.....
work with testdiv
}

Does this make sense?

Thanks,
Bryan
 
from
Code:
function scrollDiv() {
[!]   var scrollerContainer = document.getElementById("scrollerContainer");
   if (scrollerContainer) {[/!]
      scrollerPosition += scrollerDirection;
      //if we're at the end of the scroller, change the scrolling direction
      if ((scrollerPosition >= scrollerContainer.scrollTop + scrollerEndPause) || (scrollerPosition == scrollerEndPause * -1)) {
         scrollerDirection = scrollerDirection * -1;
      }
      scrollerContainer.scrollTop = scrollerPosition;
[!]   }[/!]
}

Additionally, javascript questions should be posted in forum216

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top