Reputation: 4518
Simple code that works
$(this).css({'background-image':'url(images/icons/accept.png)'});
And now the code that doesn't work
kkk='images/icons/accept.png';
$(this).css({'background-image':'url(kkk)'});
What do I do wrong ?
Upvotes: 1
Views: 72
Reputation: 700840
You can't use a variable name inside a string. Concatenate the strings:
kkk='images/icons/accept.png';
$(this).css({'background-image':'url(' + kkk + ')'});
Upvotes: 1