您现在的位置是:首页 > 电脑技术查询 > web开发

不明白咋回事

编辑:chaxungu时间:2022-10-02 23:14:21分类:web开发

不明白怎么回事,请指教
为什么不提示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>