<div class="gridmasonry grid_accomodation select_room">
<div class="item_grid item2">
<div class="panel">
<div class="img_preview">
<h4 class="price"><span>€20 </span>Night</h4>
<img src="~/Images/rooms/standard.jpg" alt="img_preview" />
</div>
<div class="clsRoomType"><h4>Standart Room</h4></div>
</div>
</div>
<div class="item_grid item2">
<div class="panel">
<div class="img_preview">
<h4 class="price"><span>€20 </span>Night</h4>
<img src="~/Images/rooms/luxury.jpg" alt="img_preview" />
</div>
<div class="clsRoomType"><h4>Luxury Room</h4></div>
</div>
</div>
<div class="item_grid item2">
<div class="panel">
<div class="img_preview">
<h4 class="price"><span>€20 </span>Night</h4>
<img src="~/Images/rooms/family.jpg" alt="img_preview"/>
</div>
<div class="clsRoomType"><h4>Family Room</h4></div>
</div>
</div>
<div class="item_grid item2">
<div class="panel">
<div class="img_preview">
<h4 class="price"><span>€20 </span>Night</h4>
<img src="~/Images/rooms/vip.jpg" alt="img_preview"/>
</div>
<div class="clsRoomType"><h4>VIP Room</h4></div>
</div>
</div>
<div class="item_grid item2">
<div class="panel">
<div class="img_preview">
<h4 class="price"><span>€20 </span>Night</h4>
<img src="~/Images/rooms/deluxe.jpg" alt="img_preview"/>
</div>
<div class="clsRoomType"><h4>Deluxe Room</h4></div>
</div>
</div>
<div class="item_grid item2">
<div class="panel">
<div class="img_preview">
<h4 class="price"><span>€20 </span>Night</h4>
<img src="~/Images/rooms/romantic.jpg" alt="img_preview" />
</div>
<div class="clsRoomType"><h4>Romantic Room</h4></div>
</div>
</div>
</div>
我有一個如上所述的DIV結構。我需要在每次點擊類「item_grid item2」的DIV項目時獲得DIV類文本「clsRoomType」使用jquery訪問另一個類中的類
我試過下面的代碼,但它顯示所有項目的文本
$(document).ready(function() {
$(".item2").click(function() {
alert($(".item2").find('div.clsRoomType').text());
});
});
當前的結果:斯坦達特間豪華間家庭間貴賓室......
我想每次點擊的每一個項目。
怎麼是不同的。 –