Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 3 个具有相同 id="UserImages" 的图像我想知道是否可以单击它们并在 jquery 中获取 scr?
首先,我将它们切换到类(ID 必须是 unqiue):
<img class="UserImages" src="..." />
然后使用选择.class器找到它们,如下所示:
.class
$("img.UserImages").click(function() { alert(this.src); });