How to set background Jquery methods?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
11 views
Hello tell me how to set the background of the item if the address of the background is stored as a url in a variable?

In the script by clicking on the element in the variable bg is added to the image url... And how this picture now to put a background of a certain element? Is it possible with css method.() ???
$(".link").click(function(){ var bg = $(this).children('img').attr('src'); }
by | 11 views

1 Answer

0 like 0 dislike
Yes it is possible.
Here is real working example:
$('.link').click(function () { var bg = $(this).children('img').attr('src'); $('body').css('background', "url('" + bg + "') no-repeat scroll transparent"); }
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
0 like 0 dislike
5 answers
0 like 0 dislike
1 answer
asked Apr 9, 2019 by ivansimonov1984
110,608 questions
257,187 answers
0 comments
40,796 users