Setting background-image using jQuery CSS property

前端 未结 11 2146
渐次进展
渐次进展 2020-11-22 10:34

I have an image URL in a imageUrl variable and I am trying to set it as CSS style, using jQuery:

$(\'myObject\').css(\'background-image\', image         


        
11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 11:12

    For those using an actual URL and not a variable:

    $('myObject').css('background-image', 'url(../../example/url.html)');
    

提交回复
热议问题