如何从中获取元素它位于使用 Javascript 的 ListView 控件内?
这是我的情况...我正在尝试使表格行可点击。这一行里面是一个 TD,它有一个链接按钮,其中包含我想从 javascript 触发的单击事件。问题是,表格位于 ListView 内部,这意味着我无法直接访问表格或行,我必须先获取 ListView 对象,然后才能到达链接按钮以调用其单击事件...我'我为此编写 javascript 遇到了困难...请帮助...谢谢。
Here's my situation... I'm trying to make a table row clickable. Inside this row is a TD that has a linkbutton with the click event that i want to trigger from javascript. The problem is, the table is inside a ListView, which means I can't access the table or the row directly, I have to get the ListView object first before i can get to the linkbutton to call its click event... I'm having a tough time writing the javascript for this... please help... thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用任何对象的 ID 从任何地方访问该对象。
另请注意,ID 区分大小写。
You can access to any object from anywhere using its ID.
Also note that the ID's are case sensitive.
您在呈现模板时创建的每个按钮都将具有略有不同的客户端 ID。您可以通过右键单击页面并选择查看源代码来验证这一点。我认为您需要做的是将以下内容更改
为:
然后更改 javascript 以在 getElementById 中使用该字符串。您可能还需要对 theRow 执行相同的操作。
希望这是有道理的。
Each of the buttons you are creating as the template is rendered are going to have a slightly different client ID. You can verify this by right clicking on the page and selecting View Source. I think what you need to do is change the following:
to something like:
Then change the javascript to use that string in your getElementById. You may also have to do the same with theRow.
Hopefully that makes sense.