Hi there! Is there a way to add a background image to a div dynamically using javascript? Right now I'm accomplishing this by setting up ID's in CSS with the specified background image and adding those ID's to div's using JS. But I was wondering if there was a way to cut out the CSS approach/middle man?
Sure there is. You may wish to check the .css() function
but generally it's something like
$el.css( 'background-image', 'url(https://domain.org/image.jpg)' );
Subject | Author | Posted |
---|---|---|
36m ago | ||
41m ago | ||
52m ago | ||
an hour ago | ||
an hour ago |