有人可以帮我理解为什么这段代码不起作用吗?
$('#quick-search-header.widget-title').css('background-image', 'url(dd_includes/images/icons/sliding-menu-arrow-right.gif)');
我通过 Firebug 看到 background-image 已完全从 中删除#quick-search-header.widget-title
,但上面的新背景图像已添加到element.style
. 谢谢。
HTML -
<div id="quick-search-header" class="widget-title">
<p>Quick search results</p>
</div>
CSS -
#quick-search-header.widget-title{
background: #C60B46 url(dd_includes/images/icons/sliding-menu-arrow-down.gif) right 3px no-repeat;
}
完整的 JS(标有错误代码)-
$(document).ready(function(){
$('input#s').val('');
$('#quick-search-header.widget-title').live('click', function(){
if($('#quick-search-content').hasClass('visible')){
$('#quick-search-header.widget-title').css('background-image', 'url(dd_includes/images/icons/sliding-menu-arrow-right.gif)'); /** Not working */
$('#quick-search-content').removeClass('visible')
$('#quick-search-content').slideUp('600');
} else {
$('#quick-search-header.widget-title').css('background-image', 'url(dd_includes/images/icons/sliding-menu-arrow-down.gif)'); /** Not working */
$('#quick-search-content').addClass('visible')
$('#quick-search-content').slideDown('600');
}
});
});