Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find first occurrence of class in div

Tags:

jquery

I have the below html structure, i want to find the inner html of first div with class as "popcontent" using jQuery

<div> <div class="popContent">1</div> <div class="popContent">2</div> </div> 
like image 404
Amit Avatar asked Jun 21 '11 10:06

Amit


2 Answers

You will kick yourself..... :)

$(".popContent:first").html() 
like image 93
Codecraft Avatar answered Oct 05 '22 03:10

Codecraft


first occurrence of class in div

$('.popContent').eq(0).html('value to set'); 

Second occurrence of class in div

$('.popContent').eq(1).html('value to set'); 
like image 37
Hitesh Modha Avatar answered Oct 05 '22 02:10

Hitesh Modha