<div data-layer="">
<div class="area-comment-left">
<a class="thumb" target="_blank" href="index.php">
<img class="avatar" src="1.jpg" data-name="www">
</a>
</div>
</div>
<a href="">GO</a>
以上,數據層的值是一個數,其用戶輸入,並有多個數據層,所以只能獲得由用戶輸入的圖像:如何獲得這樣的圖像的src?
<input class="floor" value="a number">
然後如何將「a」的href更改爲圖像的src?像這樣:
<a href="1.jpg">GO</a>
也許這會工作?
var floor = $("div[data-layer="+$('.floor').val()"] .area-comment-left .thumb .avatar").attr("src");
非常感謝您的幫助!
就像你決定'1.jpg'應該在圖像src中一樣。 –
所以,基本上你想要得到每個'.thumb'並將它的'href'設置爲它內部圖像的'src'。 –