不用判断.
try{document.all.A.value="hello";}catch(e){}
try{document.all.A.value="hello";}catch(e){}
解决方案 »
- document.body.clientWidth document.body.offsetWidth 和 document.body.scrollHeight
- jquery select 怎样正确取道text值,$("select[@name='andor']option[@selected]").text()),我这样取的值为空,为什么?谢谢,急急
- 怎样将百分数转换成小数
- 誰能幫我把這個用htm寫的表格改為svg?100的高分請高人!
- 关于Jquery点击事件替换问题。求解答
- 在javascript中命名分组的正则表达式是怎样写的,然后怎样利用命名替换或取出该命名级匹配的值?
- 怎样编写mediaplay的进度条??
- 没有Form,能直接向服务提交吗?
- textarea中输入一行字符后,回车是什么事件?
- 用JS获取别的网站页面html源代码的问题
- 救
- 请问如何设置window.open()的ie的大小?在线等
if(document.all.A.value=="")
{
document.all.A.value="hello";
}
}catch(e){}
<body topmargin="0">
<form name='form0'>
<input type='text' name='hello'>
</form>
</body>
<script language='javascript'>
for(var i=0;i<form0.elements.length;i++){
if(form0.elements[i].name=='hello'){
form0.elements[i].value='xxx';
}
}
</script>
</html>
{
if(document.forms[0].elements['A'].value==null)
{
document.forms[0].elements['A'].value="hello";
}}
else
{
document.forms[0].elements['b'].value="hello";
}
<body topmargin="0">
<form name='form0'>
<input type='text' name='hello'>
</form>
</body>
<script language='javascript'>
if(form0.hello) //判断是否存在,如果存在则是真。
{
...
}
</script>
</html>