标题很多,有一些背景图片作为项目符号,为此,padding-left: 35px;
出于某些原因,现在给出了标题,有些标题没有背景图片。因此,我想通过应用0像素删除左填充值。我该怎么做?
jQuery(document).ready(function(){
var ts = $('h1,h2,h3,h4,h5,h6');
if(!ts.style.background) ts.css({'padding-left':'0px'});
});
上面的代码不起作用。请注意:背景图片也是使用background
或给出的background-image
由于ts
是jQuery包装器元素,因此不会具有该style
属性
jQuery(document).ready(function () {
var ts = $('h1,h2,h3,h4,h5,h6');
ts.filter(function () {
return $(this).css('background-image') == 'none'
}).css({
'padding-left': '0px'
});
});
演示:小提琴
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句