1

I'm trying to make it by this code:

var $li = $('#marks').find('li[data-id=111222333]'),
color = 'rgb(' + $li.css('background-color').match(/\d+/g).map(function (i) {
    return (+i > 100 ? ((+i + 33) > 255 ? i : +i + 33) : +i + 99);
}).join(',') + ')',
gradient = 'repeating-linear-gradient(45deg, '+$li.css('background-color')+', '+$li.css('background-color')+' 3%, '+color+' 3%, '+color+' 6%);';
$li.css({'background-image': gradient});

But it doesn't works... I'm also trying this:

$li.css({'background': gradient});
$li.css('background', gradient);
$li.css('background-image', gradient);
$li[0].style.background = gradient;
$li[0].style.backgroundImage = gradient;

Butt result is same... Any ideas?!

UPD. Try here https://jsfiddle.net/kk77x3ru/

3
  • stackoverflow.com/questions/3444439/… Commented Feb 4, 2016 at 7:33
  • Does this make any difference $li.css({background: gradient});? Can you check the value in console? Commented Feb 4, 2016 at 7:33
  • Nope... No difference =( Commented Feb 4, 2016 at 7:44

1 Answer 1

1

It's because you have an unnecessary ; char in your gradient. Get rid of that

gradient = 'repeating-linear-gradient(45deg, '+$li.css('background-color')+', '+$li.css('background-color')+' 3%, '+color+' 3%, '+color+' 6%)';

UPDATED FIDDLE

Sign up to request clarification or add additional context in comments.

1 Comment

@m0sk1t glad I could help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.