Question for the HTML5 Brainiacs of GFY
Greetgins and salutations!
I have a question for the HTML5 gurus:
How can I display a default image in HTML5 if the image I want is not available?
Here's a piece of code:
<div style="background-image: url(images20/intro.jpg);">
But in certain circumstances, the file named intro.jpg will not always exist. So when this file does not exist, I want it to load a different image. For example, default.jpg
I can do this already with a standard IMG tag, like this:
<img id="currentPhoto" src="intro.jpg" onerror="this.src='Default.jpg'">
But how do I do it when using a background image in a div?
|