[Javascript] getting the id of the parent tag

Andrew Gibson andyg at ihug.co.nz
Mon Jul 14 17:35:36 CDT 2003


My trusty Danny Goodman DHTML book gives parentElement()  property for the
text range object.

So, some thing like:
var p=myRange.parentElement().id   ?

But, as far as I know, only a solution for IE 6

Andrew Gibson




>>>>>>>>>>
Subject: RE: [Javascript] getting the id of the parent tag
Oops.

Upon reading your message again, I realized that climbing the
DOM wasn't your main problem.  Textrange should do it, as already
suggested.

-----Original Message-----
From: Peter Brunone [mailto:peter at brunone.com]

Sachin,

In IE, I know you can object.parentElement.id property of most
tags; this seems to be a standard, or at least close to it, so I'd be
surprised if it didn't work in Netscape 6 and 7.

Cheers,

Peter

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Sachin Zingade

Hi,

I need to get the id of the parent tag when i select some text from that
tag.

Example:

<p id="209202920290"> This is test para This is test para This is test
para This is test para</p>

So when i select " test para " i should get "209202920290".


Next requirement is

<p id="209202920290"> This testststst <i> This is test para </i> test
para</p>

So when i select " is test para"  which is inside the italic tag , i
should get "209202920290".

If any one can reply it would be great

Sachin Z





More information about the Javascript mailing list