Development| HTML| JavaScript| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JavaScript parentElement method 
 

JavaScript's parentElement() method returns reference to the parent element of the specified element.

 

JavaScript parentElement method

                         

JavaScript's parentElement() method returns reference to the parent element of the specified element. By using the parentElement() method we can obtain any element's parent element object reference which may be very useful while we have many overlapped elements and we are not able to find the exact references to the parent elements.

Syntax :

document.elementObject.parentElement();

Where elementObject is the object of which parentElement reference we have to take. Here is the full HTML code of parentElementExample.html as follows:

 

 

 

<html>
  <head>
    <title>parentElement method</title>
    <script language="JavaScript">
	function callParentElement() {
	  var range = document.selection.createRange();
	  var parElement = range.parentElement();
	  parElement.innerText = 'ParentElement'; 
	} 
    </script>
  </head>
  <body>
    <div style="background: #99ffcc; width:'100%';" 
          align="center">
      <font color="#ff0000" size="12pt">
	<b>parentElement method example</b>
      </font>
    </div>
   <center>
     <p>&nbsp;</p>
	<input type="button" value="Call Parent"
            onclick="callParentElement();">
   </center>
  </body>
</html>

Output :

Click on the button "Call Parent", it will find the parent element and will take the reference of it into an object variable.

Download Source Code

                         

» View all related tutorials
Related Tags: java javascript c attributes script reference object method sed remove ip attribute node move nat to ref e it alter

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.