Is there a way to set background-image as a base64 encoded image?

后端 未结 9 2281
执念已碎
执念已碎 2020-12-02 16:09

I want to change background dynamically in JS and my set of images is in base64 encoded. I try:

document.getElementById(\"bg_image\").style.backgroundImage =         


        
9条回答
  •  执念已碎
    2020-12-02 17:07

    In my case, it was just because I didn't set the height and width.

    But there is another issue.

    The background image could be removed using

    element.style.backgroundImage=""

    but couldn't be set using

    element.style.backgroundImage="some base64 data"

    Jquery works fine.

提交回复
热议问题