How to remove a registration if the title does not have a background image?

There are many headers, and some have a bullet-shaped background image, and for this purpose headers are padding-left: 35px;now given for some reason, some headers have no background image. So I wanted to remove the padding-left value by applying 0 pixels. How can I do something like this?

jQuery(document).ready(function(){
    var ts = $('h1,h2,h3,h4,h5,h6');
    if(!ts.style.background) ts.css({'padding-left':'0px'});
});

The code above does not work. Please note: the background image is also set using backgroundorbackground-image

+4
source share
1 answer

Since it tsis a jQuery wrapper element, it will not have a propertystyle

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'
    });
});

demo: fiddle

+2
source

All Articles