我正在尝试使用jQuery为我的某个HTML元素设置背景图像
<div class="rmz-srchbg">
<input type="text" id="globalsearchstr" name="search" value="" class="rmz-txtbox">
<input type="submit" value=" " id="srchbtn" class="rmz-srchico">
<br style="clear:both;">
</div>
$("#globalsearchstr").focus(function(){
$(this).parent().css("background", "url(/images/r-srchbg_white.png) no-repeat;");
});
但这从来没有起作用。只有在焦点上,才会向HTML添加样式属性,就像这样:
<div class="rmz-srchbg" style="">
</div>
CSS没有发生任何改变。