If you have the following divs:
<div class="container>
<div class="something">some text</div>
</div>
<div class="container>
<div class="something">some text</div>
</div>
<div cl开发者_StackOverflowass="container>
<div class="something">some text</div>
</div>
When you click on class container, how can you get the text for class something?
$(".container").click(function(){
var somethingText = $(this).find(".something").text();
});
$('.container').click(function(){
var something = $('.something', this);
alert(something.text());
});
use jquery Selector Context http://api.jquery.com/jQuery/
精彩评论