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!

Execute code if div exists 1

Status
Not open for further replies.

Geee

Programmer
Apr 23, 2001
253
GB
I am trying to execute a function only if an element with that id exists on the document. I am trying something like:

JavaScript:
if (divObj = document.getElementById("container")) {
	Execute Function
}

But to no avail, am I treading the right path?

Thanks in advance,

G

-Geeeeeeeeeeeeeeeeeeeeeeee-
 
Almost!

Code:
if (document.getElementById("container")) {
    Execute Function
}

Cheers

Nick
 
Thank you!

-Geeeeeeeeeeeeeeeeeeeeeeee-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top