點擊p元素上後,我有這樣的代碼:獲取圖像的ID在下拉菜單中
<table class="canToggle">
<tr>
<td>
<div class="messagepop pop">
<p class="selection">moss</p>
<p class="selection">gray</p>
<p class="close">Cancel</p>
</div>
<img src="images/gray.jpg" class="wide high image" id="x1y1" />
</td>
...
</tr>
<table>
當我點擊p
S的一個,我需要得到img
的ID,這樣我可以更改img src
。我有這個jQuery:
var $selection = $(this).text();
$selection = "images/" + $selection + ".jpg";
// I need to populate the value of nextImgID for the next line
$(nextImgID).attr('src', $selection);
我想不通如何遍歷這個。我在這裏看過api和一些問題,但事情取決於兄弟姐妹關係。我將不勝感激任何幫助。
哇,成功了!謝謝!我正在全力以赴,從來沒有做到。 – pixelmeow