Search code examples
javascripthtmlcss

How to use triple quotation marks for inline JS in HTML


I have a page where I can't use <script></script> and I have to place inline JS within the HTML.

I'm having trouble finding a triple quotation to change the css background-image URL via JS where I'm already using single and double quotation marks e.g.

<div onmouseover='document.getElementById("anotherDiv").style.backgroundImage = "url("https://www.test.com/image.jpg")";"></div>

where I need a triple quotation mark to wrap:

url("https://www.test.com/img/20-test-1.jpg")

Any thoughts?


Solution

  • You don't need to add quotation for url(), do this

     <div onmouseover="document.getElementById('anotherDiv').style.backgroundImage = 'url(https://www.test.com/image.jpg)'"></div>