Guest  

Welcome Guest, posting in this forum requires registration.

Pages: [1]
Topic: How to get current element parent id in jquery?
Guest
Member
Posts: 39

Reputation: 55
How to get current element parent id in jquery?
on: March 3, 2016, 11:48

How to get current element parent id in jquery?

Example:
<div id="parentdiv">
<div id="childdiv"></div>
</div>

I want to fetch "parentdiv" from "childdiv". How I can do this?

Guest
Member
Posts: 61

Reputation: 105
Re: How to get current element parent id in jquery?
on: March 3, 2016, 15:05

You can use parent() of jquery.

In your example:
$("#childdiv").parent().attr('id');

Pages: [1]
WP Forum Server by ForumPress | Lucid Crew
Version: 1.8.2 ; Page loaded in: 0.01 seconds.

Share This: