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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with trying to find an element

Status
Not open for further replies.

MaRiJaWaNa

Programmer
Jun 18, 2008
3
CA
Alright i got this code

try {
var menu = document.getElementbyID("awmAnchor-menu");
} catch(err) {
try {
var menu = document.getElementbyID("nomenu");
} catch (err) {
//Do Nothing
}
}

and the reason it tries both is because the id could be both is this wrong?
 
Also is this how you change a class?

menu.className = "awmAnchor-menu";
 
var menu;
try {
menu = document.getElementById("awmAnchor-menu");
} catch(err) {
try {
menu = document.getElementById("nomenu");
} catch (err) {
//Do Nothing
}
}

Doesn't seem to work any idea's?
 
Perhaps showing the rest of your code (or better still, a URL) and explaining what the code doesn't do that it should would help?

The small snippet you've given looks good in isolation, but we have no idea what else on the page is happening.

For example, we have no idea whether you actually have elements on the page with IDs of 'awmAnchor-menu' or 'nomenu' at the time the code is run.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top