我正在尝试向没有 id 或类的图像添加文本行我有一系列图像,例如
<img src="../img/star.png" /><span>no text here until left img is clicked</span>
<img src="../img/someotherpicture.png" /><span>no text here until left img is clicked</span>
<img src="../img/anotherpicture.png" /><span>no text here until left img is clicked</span>
对于 jquery 我有
$(document).ready(function(){
$("img").click(function(){
$("img").next.$("span").val("info inserted after clicking on the img next to spa");
})
});
我有点困惑我应该如何在这里使用 next ,或者我应该使用 find ?我总是有一个 img 后跟一个 span。