如何找到任何控件的子控件 [英] how to find child controls of a any control

查看:97
本文介绍了如何找到任何控件的子控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经拿着桌子,其中有tableRows和tablerows有单元格,单元格有控件(文本框)。[Table-> TableRow-> Cells-> Textbox]



所以如何找到文本框...



例如:==

var tb = dialog.childNodes [3 ];





(其中对话框为DIV)

i have taken table in which there are tableRows and tablerows have cells and cells have controls (textbox).[Table->TableRow->Cells->Textbox]

so how to find textbox...

For Example:==
var tb=dialog.childNodes[3];


(where dialog is DIV)

推荐答案

相似解决了QA:

使用javascript获取表格行中asp:textbox的值 [ ^ ]
Similar solved QA:
get value of asp:textbox in table row with javascript[^]


其中一个解决方案是使用jQuery,其方法 .children()

http://api.jquery.com/children/ [ ^ ]。



您也可以使用方法 jQuery.each()

http://api.jquery.com/jQuery.each/ [ ^ ]。



例如:

One of the solutions would be using jQuery, its method .children():
http://api.jquery.com/children/[^].

You can also use it with the method jQuery.each():
http://api.jquery.com/jQuery.each/[^].

For example:
someElement =


#someId); // 或其他一些选择器
jQuery.each(someElement.children(), function (){
child = this ;
// 为每个孩子做点什么
});
("#someId"); // or some other kind of selector jQuery.each(someElement.children(), function() { child = this; // do something with each child });





您甚至可以递归地执行此操作,遍历某些类型的直接和间接子项,CSS类或类似的东西。



另请参阅: http://api.jquery.com/category/selectors/ [ ^ ]。



如果你需要学习jQuery(强烈推荐),请参阅:

http://en.wikipedia.org/ wiki / JQuery [ ^ ],

http://jquery.com/ [ ^ ],

http://learn.jquery.com/ [ ^ ],

http://learn.jquery.com/using-jquery-core / [ ^ ],
http://learn.jquery.com/about-jquery/how-jquery-工作/ [ ^ ](从这里开始)。



-SA



You can even do it recursively, to traverse all direct and indirect children of some type, CSS class or something like that.

See also: http://api.jquery.com/category/selectors/[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com/[^],
http://learn.jquery.com/[^],
http://learn.jquery.com/using-jquery-core/[^],
http://learn.jquery.com/about-jquery/how-jquery-works/[^] (start from here).

—SA


这篇关于如何找到任何控件的子控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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