Solved

Jquery or JavaScript - get the father of element

Posted on 2014-09-08
1
351 Views
Last Modified: 2014-09-08
Hi E's,
I need help to get a father of element.
I try this code in Jquery:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>pai do elemento em jquery</title> 
<script src="../../ficheiros_apoio/jquery.min.js"></script>
</head> 
<body> 
<div id="pai">
<div class="filho">eu sou o filho</div>
</div>
<script>
var info = $(".filho").parent();
$.each(info, function( index, value ) {
  alert( index + ": " + value );
});

</script>
</body> 
</html> 

Open in new window

But not work.
What is the solution for get the Id "pai"?

The best regards, JC
0
Comment
Question by:Pedro Chagas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40309684
value.id
var info = $(".filho").parent();
$.each(info, function( index, value ) {
  alert( index + ": " + value.id );
});

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question