Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-11-2012, 12:29 PM   PM User | #1
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
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.
__________________
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

Last edited by BubikolRamios; 11-11-2012 at 12:32 PM..
BubikolRamios is offline   Reply With Quote
Old 11-11-2012, 01:09 PM   PM User | #2
DaveyErwin
Regular Coder

 
Join Date: Aug 2010
Posts: 814
Thanks: 12
Thanked 168 Times in 166 Posts
DaveyErwin is on a distinguished road
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..
DaveyErwin is offline   Reply With Quote
Old 11-11-2012, 03:03 PM   PM User | #3
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
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
BubikolRamios is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:36 AM.


Advertisement
Log in to turn off these ads.