0
所有節點的文字我有這樣一個div:jQuery的如何選擇DIV
<div class="movie">
Date:
<span class="date"> June 12, 1987 </span>
Título:
<span class="title">
<a class="select_movie" href="#">
Predator
</a>
</span>
Director: <span class="director">John McTiernan</span>
Starring: <span class="starring">Arnold Schwarzenegger</span>
</div>
我想在<div class="movie">
所有文本節點,鏈接.select_movie
$('.select_movie').click(function(){
..........
..........
});
的在點擊後我需要檢索要分配給變量的節點的值的結尾,如下所示:
var date = June 12, 1987;
var title = Predator;
var director = John McTiernan;
var starring = Arnold Schwarzenegger;
猜測這裏,但可能有多個電影上這一頁。也許追求最接近的.movie對OP有幫助? – dc5 2014-08-27 16:19:08
@ dc5是的,也許有,好點。我剛剛更新了它 – 2014-08-27 16:20:43
這是非常有用的回覆,我工作的是: var title = $(this).parent('span')。parent('div')。children('。title')。text( ); – user1034380 2014-08-27 16:49:28