[thelist] DOM Help
Peter Brunone (EasyListBox.com)
peter at easylistbox.com
Thu Feb 3 11:20:55 CST 2005
Hi Tony,
For a good book, I don't know, but if you find one, be sure to share.
Re. parents, I know that in IE (not sure if this is standard) you can say object.parentElement, and then check the .tagName of that element to see if it's equal to "DIV", at which point you can perform your action on it.
Cheers,
Peter
From: Tony Grimes info at scribenewmedia.com
Is there any way to "walk" the DOM in javascript to find a given tag's
ancestor/parent or child tags (like you can in XSL)?
For example, I've written a javascript to show or hide a paragraph tag when
someone clicks on a link. Right now, each paragraph has a unique id so the
script knows which one to show/hide, but I'd like to make it simpler to
implement.
Here's the HTML I use now:
================
Header Text return false;" href="#">Show/Hide Description
This is description to Show/Hide.
=================
But I'd like to use this:
================
Header Text return false;" href="#">Show/Hide Description
This is description to Show/Hide.
=================
What I'd like to do from within the script is:
1. Find the tag that surrounds the tag that was clicked.
2. Access the
object that lies within the same tag (to change it's
css properties).
Is there any way navigate the DOM like this in javascript? And while I'm on
the subject, is there a good book available on the DOM? All I can find are
single chapters in books about javascript etc.
TIA
Tony
More information about the thelist
mailing list