Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    get this element placement within parent

    Code:
    <table>
      <td>
      </td>
      <td onclick = "somefunction (this);">
      </td>
      <td>
      </td>
    </table>
    Is it possible that somefunction would return 1 (via parentNode.getelementsbytagname), as this is second td within table ?
    No id's, no nothing on elements inside table.
    Last edited by BubikolRamios; 11-11-2012 at 12:32 PM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    972
    Thanks
    19
    Thanked 212 Times in 210 Posts
    Code:
     
    <script>
    function somefunction(el){
        var count=0;
        var nodes=el.parentNode.getElementsByTagName(el.tagName);
            while(nodes[count++])
                if(nodes[count-1] === el) 
                   alert(count-1);
    };
     
    </script> 
    <body>
    <table> <td> </td> <td onclick = "somefunction (this);"> clickMe </td> <td> </td> </table>
    </body>
    Last edited by DaveyErwin; 11-11-2012 at 02:16 PM.

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Thanks.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

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