Я пытаюсь установить фон элемента в градиент, но он не устанавливается. Он добавляет style=""
для разметки и работает, когда я помещаю код непосредственно в firebug (я использую Firefox). Любая идея, почему он не работает или как я могу заставить его работать?
$('main > article').each(function (index) {
var bg = $(this).css('background-color');
var nextbg = $(this).next().css('background-color');
if ($(this).next().length && nextbg != bg) {
$(this).css('background', 'linear-gradient(to bottom, ' + bg + ' 0%, ' + nextbg + ' 100%);');
console.log('linear-gradient(to bottom, ' + bg + ' 0%, ' + nextbg + ' 100%);');
console.log('------------');
}
});
Просто удалите ";" в конце вашего css
('main > article').each(function (index) {
var bg = $(this).css('background-color');
var nextbg = $(this).next().css('background-color');
if ($(this).next().length && nextbg != bg) {
$(this).css('background', 'linear-gradient(to bottom, ' + bg + ' 0%, ' + nextbg + ' 100%)');
console.log('linear-gradient(to bottom, ' + bg + ' 0%, ' + nextbg + ' 100%);');
console.log('------------');
}
});