Lire le backgroundImage de mon DIV avec getElementById
Bonjour,
Je n'arrive pas à lire, avec un getElementById, le nom de mon image contenu dans un DIV. En revanche, l'image s'affiche bien à l'écran.
Voici mon code
SCRIPT
Code:
1 2 3 4 5 6 7
|
function AfficheInfo(DivId)
{
alert("Nom de l'image : " + document.getElementById(DivId).style.backgroundImage);
}
AfficheInfo("div_image"); |
CSS
Code:
1 2 3 4 5 6 7 8
|
#div_image { position:absolute;
width:333px;
height:250px;
top:50px;
left:33px;
background-color:none;
background-image:url("Diapo/Novotel.jpg");} |
HTML
Code:
1 2
|
<div id="div_image"></div> |
La syntaxe dans mon message alert est-elle fausse ?
Sauriez-vous comment je peux faire afficher le nom de mon image avec alert() ?
Merci.