/    Sign up×
Community /Pin to ProfileBookmark

Getting node index?

Hi,

I have had a look at the official documentation, and i was wonderingif theres a way to get the position of a node in the parent node.

For example say I have

[code]

<div>

<div></div>

<div id=”mydiv”></div>

<div></div>

</div>
[/code]

How would i get the position of the div ‘mydiv’? Is there a cross browser way to do this?

Thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoJul 26.2006 — check the childNodes of the first div, and then see if their id is what you want.
×

Success!

Help @idn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...