MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

How to get the first element of the child using Jquery ?

0
Started on: 15 February 13
Participants: 1
I am using jquery to change my element style.I want to get the first child element from a parent div.

my example
<div id="parent_div">
<div class="child1">
<div class="child11">
</div>
<div class="child12">
</div>
</div>
<div class="child2">
<div class="child21">
</div>
<div class="child22">
</div>
</div>

</div>
from the above html i want to get only the first child of the parent div

i tried below jquery code but it takes all the child
$("#parent div").each(){

}
help me to get the first child only , child1 element for the above example.

























I am using jquery to change my element style.I want to get the first child element from a parent div.

my example

from the above html i want to get only the first child of the parent div

i tried below jquery code but it takes all the child

$("#parent div").each(){

}

help me to get the first child only , child1 element for the above example.

This challenge is listed under Development & Implementations Community

Initiator

Aravinthan
Aravinthan
  Follow

I am passinate about IT & PHP , Let's do it

More posts by: Aravinthan Asokan

1 Suggestion

  1. 20 February 13
    0

    try the below jquery

    $("#parent").each(){ $(this).children("div:first").attr("id") }

Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top