Last active
August 29, 2015 14:16
-
-
Save codenamejason/e9293841054032957ae3 to your computer and use it in GitHub Desktop.
Change background image with button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#imgDiv { | |
width: 400px; | |
height: 400px; | |
background-image: url('http://placehold.it/400.png&text=New_Image/464545/e743c3'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<button onClick="myFunction()">Change Background</button> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
document.getElementById("imgDiv").style.backgroundImage = "url(http://placehold.it/400.png&text=New_Image/464545/e743c3)"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment