我有以下线的问题:jQuery和CSS背景变化
document.getElementById("giftcard").getElementsByTagName("label").style.backgroundImage ="url(giftcard_icon-d.jpg)";
我想点击一个label
后更改背景图片。
我在页面上有5 label
s,但是当我点击label
时,背景应该改变它。其他标签应该重置为使用这个giftcard_icon-d.jpg
图片作为他们的背景。
我该如何解决这个问题?
$(document).ready(function() {
$('#giftcard label').click(function() {
document.getElementById("giftcard").getElementsByTagName("label").style.backgroundImage ="url(giftcard_icon-d.jpg)";
this.style.backgroundImage ="url(giftcard_icon-a.jpg)";
});
你能发表一些html吗? – LostLin 2011-04-27 20:25:25
究竟发生了什么?他们都没有背景变化? – 2011-04-27 20:27:19