变化的值与if
<!DOCTYPE html>
<html>
<head>
<script>
window.onload=function ()
{
var oDiv=document.getElementById('p1');
var value=1;
setInterval(function(){
oDiv.innerHTML=value;
value++;
if(value>2){
value=1;
}
},1000);
var a1=document.getElementById('p1').innerHTML;
if(a1==1)
{
document.getElementById("l").style.display="none";
document.getElementById("m").style.display="block";
}
if(a1==2)
{
document.getElementById("m").style.display="none";
document.getElementById("l").style.display="block";//问:为什么无法随着a1的变化而变化?
}
}
</script>
</head>
<body>
<img id="l" src="/i/eg_bulbon.gif">
<img id="m" src="/i/eg_bulboff.gif">
<p id="p1"></p>
</body>
</html>