<input type="button" id="button1" value="test">
<script>
alert(document.getElementById("button1")==null?"button1不存在":"button1存在")
</script>
可以修改id="其它名字"看看
<script>
alert(document.getElementById("button1")==null?"button1不存在":"button1存在")
</script>
可以修改id="其它名字"看看
解决方案 »
- 载入多个jQuery运行库冲突,求解决办法!!
- JQuery UI Tabls 传值问题
- 请教xml文件中路径如果包含变量运算应该如何写
- 用JS代码实现在原网页的界面上弹出一个新的登陆界面
- 谁来解释一下 Function.prototype.isPrototypeOf(Object) 是true ?
- 文件夹名称的正则问题
- 倒计时程序的修改,如何开始/暂停两个按钮的功能改成一个
- 如何实现flash在王页上的透明效果?
- jquery的autoComplete正则表达式中如何修改为只匹配开头的字母?
- echarts折线图多条折线的时候怎么控制每次只能限制1条
- 关于日期格式规范的问题。急!
- 表单提交后在php中获得$messenge="..."(字符串)
if (e != null)
{
alert ("存在")
}
else
{
alert ("不存在")
}
....
<input id=button1>
<input id=button2><script>
function check(str){
alert(str+":"+(document.all(str)!=null?"存在":"不存在"))
}
check("button1")
check("button2")
check("button3")
</script>
<input id=button1>
<input id=button2>
<script>
function check(str){
alert(str+(document.all(str)==null?"不":"")+"存在")
}
check("button1")
check("button2")
check("button3")
</script>