SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: table DOM ref

  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    table DOM ref

    hey...does anybody know what the corect DOM reference to a div layer within a table is? I want to change the class of the div but can't figure out how to do it....

    Sketch
    Aaron Brazell
    Technosailor



  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    does nobody notice my practices

    DOM doesn't figure the div as an individual element under the bubble hierarchy of the table.

    you COULD refer to it as:

    document.all.divname.whatever...

    if this doesn't work.. USE MY BLOODY PRACTICES

    var de=document.getElementById;

    now you can get any element with an id.
    de('divid').style.color='#009933';

    OR if you want it more dom safe..
    alert(de('divid').offsetParent.tagName);

    that will show you where it is in the hierarchy, though really... the first document.all should work!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2002
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a quick example I put together. It will swich the div's className from classone to classtwo..
    <body>


    <style>
    .classone{background-color:red;}
    .classtwo{background-color:blue;}
    </style>



    <table cellspacing="2" cellpadding="2" border="0">
    <tr>
    <td>

    <div id="divid" class="classone">
    DIV DIV DIV
    </div>

    </td>
    </tr>
    </table>


    <script language="JavaScript1.2" type="text/javascript"><!--

    function classswap(){

    if(document.getElementById){classname = document.getElementById("divid")}
    else{classname = document.all.divid}

    classname.className = "classtwo"

    //alert(classname.className)

    }classswap()
    //--></script>
    </body>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •