简体   繁体   English

如何从JavaScript访问转发器项目

[英]How to access repeater items from JavaScript

I've got a hidden control inside a repeater. 我在中继器中有一个隐藏的控件。 How can I access this from JavaScript? 如何从JavaScript访问此内容?

Are you using JQuery? 您正在使用JQuery吗? This can be easily done by the following: 这可以通过以下操作轻松完成:

$("#<%= Repeater1.ClientID %>").find("input[type='hidden']")

Which scours the entire repeater; 搜寻整个中继器; because each item doesn't render a wrapper around it (a div or a table, for example), the find does an entire check of the HTML tree. 因为每个项目都不会在其周围呈现包装器(例如,一个div或一个表),所以查找会对HTML树进行完整检查。 Otherwise, you'd have to loop through each element, or wrap each item with a DIV, and access the childNodes collection of that DIV, and it would be more of a pain without JQuery, but very possible. 否则,您将不得不遍历每个元素,或者用DIV包装每个项目,并访问该DIV的childNodes集合,如果没有JQuery,这将更加痛苦,但是很有可能。

HTH. HTH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM