[Javascript] Walking the DOM
Matt Warden
mwarden at gmail.com
Fri Sep 8 17:33:24 CDT 2006
On 9/8/06, Terry Riegel <riegel at clearimageonline.com> wrote:
> If I have the following markup...
>
> <li class="anor" id="album01"><a href="album1.html">My Favorite
> Photos (58)</a></li>
>
>
>
> and... in my javascript I have...
>
> o=document.getElementById('album01');
>
>
>
> How do I reference (with the intent of changing) the content of the
> anchor? My goal is to replace the text with an updated number from
> the server, but I need a method to replace the text. As a side
> question should I be using innerHTML, or is there a better method. If
> anyone is using prototype and knows of a method through that library
> that would be helpful.
var li = document.getElementById('album01');
var anchor = li.firstChild;
var textNode = anchor.firstChild;
http://www.devguru.com/technologies/xmldom/QuickRef/node_replaceChild.html
--
Matt Warden
Cleveland, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
More information about the Javascript
mailing list