日期:2014-05-16  浏览次数:20342 次

不明白怎么回事,请指教
为什么不提示hello world呢?
<form name="ok1">
<input type="text" name="a1"/>
<br><input type="text" name="a2"/>
<br><input type="button" value="ttp"/>
<br><span id="t1"></span>
</form>
<script type="text/javascript">
var a1=document.ok1.a1.value;
var a2=document.ok1.a2.value;
if(a1="")
{
document.write("Hello world");
}
else
{
document.write("H131312ello world");
}
</script>

------解决方案--------------------
if(a1=="")
------解决方案--------------------
<form name="ok1">
<input type="text" name="a1"/>
<br><input type="text" name="a2"/>
<br><input type="button" value="ttp"/>
<br><span id="t1"></span>
</form>
<script type="text/javascript">
var a1=document.ok1.a1.value;
var a2=document.ok1.a2.value;
if(a1=="")
{
document.write("Hello world");
}
else
{
document.write("H131312ello world");
}
</script>