<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head><body>
<form method=post action="" name="form1">
<input type="button" onclick = "alert(this.parentNode.tagName + '-' + this.parentNode.name)" value="click1">
</form><form method=post action="" name="form2">
<input type="button" onclick = "alert(this.parentNode.tagName + '-' + this.parentNode.name)" value="click2">
</form>
</body>
</html>//如果有多个parentNode,一直递归找到tagName =FORM的那个
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head><body>
<form method=post action="" name="form1">
<input type="button" onclick = "alert(this.parentNode.tagName + '-' + this.parentNode.name)" value="click1">
</form><form method=post action="" name="form2">
<input type="button" onclick = "alert(this.parentNode.tagName + '-' + this.parentNode.name)" value="click2">
</form>
</body>
</html>//如果有多个parentNode,一直递归找到tagName =FORM的那个
解决方案 »
- 用jquery实现ie6对div:hover属性的支持,遇到了问题,大家帮忙解决下
- 如何在web页面的datagrid中用方向键来控制焦点
- 怎么从文本框内将光标前面的文本(带html标签)截取,急用,希望会的人能指点一下
- js代码请教
- 通过css怎样固定表格显示图片的大小
- 跪求:一个页面提交问题的答案,急啊~给出意见的大哥都有分
- onload 事件中 怎么使窗口不关闭?弹出对话框,让用户选择,但选 取消却还是离开了?
- uploadify3.2 ie8 以上高版本 ie9 ie10 ie11 文件选择按钮无法点击
- jq中点击checkbox事件,记住密码
- EasyRec推荐系统,谁用过这个啊,可以来帮帮忙吗
- 怎样实现个性的滚动条
- 大家好谁知道像这网站里的树形菜单http://ymmz.nease.net/txsub/007.htm如果子菜单展开下面还有子菜单 子菜单还可以展开子菜单 那怎么做
function mysearch(obj)
{
for(i=0;i<document.forms.length;i++)
for(j=0;j<document.forms[i].elements.length;j++)
if(document.forms[i].elements[j]==obj)
{alert(document.forms[i].name);break;}
}
</script>
<form name=form1>
<input>
<input type=button onclick=mysearch(this)>
</form>
<form name=form2>
<div>
<input type=button onclick=mysearch(this)>
<input>
<input>
</div>
</form>
<form name=form3>
<p>
<input type=button onclick=mysearch(this)>
</p>
</form>
<form name=form4>
<input type=button onclick=mysearch(this)>
</form>