我想添加图像到按钮,一旦点击使用jquery.I无法添加图像。将背景图像添加到jquery中的按钮
这里是jQuery代码
$('#b2').click(function(){
alert("b2 am called");
$(this).addClass("bg1");
});
下面是CSS
.bg1
{
background-image: url(info.jpg);
background-repeat: no-repeat;
border: none;
}
input#b2
{
position:absolute;
left:370px;
top:130px;
width:90px; /*same as the height*/
height:90px;
}
这里是HTML代码
<div id="level_1"class="Level1">
<input type="button" id="b2" value="" name="b2" >
</div>
这里是:JS Fiddle
尝试使用'!important'在'.bg1'类 – 2014-12-04 11:31:40
适用于[Fiddle](http://jsfiddle.net/chipChocolate/0wmao9ny/)。你看到'alert()'吗?如果没有,你不包括jQuery库的链接。 – 2014-12-04 11:34:24
我可以看到警报 – 2014-12-04 11:37:02