Uncaught ReferenceError: url is not defined
10,489
You're missing the quotes:
this.style.backgroundImage = 'url(img/phone-screen.jpg)';
Author by
Carlos Guevara
Updated on June 08, 2022Comments
-
Carlos Guevara almost 2 years
So I created a an iphone out of pure css and I am trying to make the screen change on click to make it interactive. I am new to java script, just started learning about it a week or so ago, and browser is telling me "Uncaught ReferenceError: url is not defined" not sure what i'm doing wrong. Any advice on why it is telling me this, so I make sure not to make the same mistake in the future. I am sure it is a simple fix just not sure how to go about it.
<div id="iphone-border"> <div id="off-button"></div> <div id="mute-button"></div> <div id="volume-up-button"></div> <div id="volume-down-button"></div> <div id="side-lines-1"></div> <div id="side-lines-2"></div> <div id="iphone-color"> <div id="camara"></div> <div id="sensor"></div> <div id="speaker"></div> <div id="iphone-screen" onClick="this.style.backgroundImage=url(img/phone-screen.jpg);" > </div> <div id="home-button-border"> <div id="home-button-color"></div> </div> </div> </div>
-
Bergi over 9 yearsThis is a javascript command, trying to invoke the function
url
. You want a string literal.
-