开发者

Selecting text within another div- jquery

开发者 https://www.devze.com 2023-03-11 00:36 出处:网络
If you have the following divs: <div class=\"container> <div class=\"something\">some text</div>

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消