this.form对象 [英] this.form object

查看:102
本文介绍了this.form对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这上面写了一个空白。


我有像这样的HTML:


< form name =" test1" ;>

< input name =" inp1" onclick =" alert(this.parent.form);">

< a href =" javascript :void(null);"

onclick =" alert(this.parent.form);">点击< / a>

< / form>


当我点击输入时我得到[对象],当我点击链接时我得到

undefined。


我想得到[对象] ]当我点击链接时显然

缺少一些东西。


Mike

I''m drawing a blank on this.

I have html like:

<form name="test1">
<input name="inp1" onclick="alert(this.parent.form);">
<a href="javascript:void(null);"
onclick="alert(this.parent.form);">click</a>
</form>

when I click the input I get [object], when I click the link I get
undefined.

I want to get the [object] when I click on the link and obviously
missing something.

Mike

推荐答案

mike写道:
mike wrote:
我有像:

< form name =" test1">
< input name =" inp1" onclick =" alert(this.parent.form);">
< a href =" javascript :void(null);"
onclick = " alert(this.parent.form);">点击< / a>
< / form>
当我点击输入时我得到[对象],当我点击我得到的链接
未定义。

当我点击链接时我想得到[对象]并且明显地错过了什么。
I have html like:

<form name="test1">
<input name="inp1" onclick="alert(this.parent.form);">
<a href="javascript:void(null);"
onclick="alert(this.parent.form);">click</a>
</form>

when I click the input I get [object], when I click the link I get
undefined.

I want to get the [object] when I click on the link and obviously
missing something.




'a''元素是`form''元素的后代不是

表单元素'集合的一部分也没有'形式'''属性;

简称,除了在解析树中的位置外,DOM中的链接和表单之间没有

连接。


我甚至想知道为什么`this.parent''首先起作用。也许在IE中,

作为其DOM的专有属性,当然不是W3C DOM

(Moz / FF / Opera) - 那就是`parentNode''。

PointedEars



`a'' elements that are descendants of `form'' elements are not part of
the forms element''s collection nor do they have a `form'' property;
in short, apart from their position in the parse tree, there is no
connection between link and form in the DOM.

I wonder even why `this.parent'' works in the first place. Maybe in IE,
as a proprietary property of its DOM, certainly not the W3C DOM
(Moz/FF/Opera) -- that would be `parentNode''.
PointedEars


mike写道:
< input name =" inp1"的onclick = QUOT;警报(this.parent.form);">


尝试:

this.form

(每个输入都有一个''form''属性,它引用包含的形式它)

< a href =" javascript :void(null);"
onclick =" alert(this.parent.form); ">点击< / a>
<input name="inp1" onclick="alert(this.parent.form);">
Try:
this.form
(every input has a ''form'' property which refers to the form containing it)
<a href="javascript:void(null);"
onclick="alert(this.parent.form);">click</a>




尝试:

this.parentNode

(父节点*是*表格标签)


-

Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


>`a''元素是`form''元素的后代不是
>`a'' elements that are descendants of `form'' elements are not part of
form elements'的集合的一部分也没有`form''属性;简而言之,除了它们在解析树中的位置之外,没有
DOM中链接和表单之间的连接。
the forms element''s collection nor do they have a `form'' property;
in short, apart from their position in the parse tree, there is no
connection between link and form in the DOM.




糟糕,所以如果我知道表格名称如下:


< a href =" javascript :void(null);"

onclick =" myfunc(''test2'')"> click< / a>


函数myfunc(obj)

{alert(document.obj);}


但是我得到了未定义的,我想要的是[对象]。 />

alert(document.form [obj]);


也不起作用



Bummer, so if I knew the form name like:

<a href="javascript:void(null);"
onclick="myfunc(''test2'')">click</a>

function myfunc(obj)
{alert(document.obj);}

but I get undefined, what I want is [object].

alert(document.form[obj]);

does not work either


这篇关于this.form对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆