jquery选项卡中的隐藏元素不可见
我使用 jquery 选项卡小部件,并使用另一个 aspx 页面的内容填充每个选项卡面板。 看起来像这样:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="tabs">
<ul>
<li><%: Html.ActionLink("PENDING", "PendingList", "Admin")%></li>
<li><%: Html.ActionLink("APPROVED", "ApprovedList", "Admin")%></li>
<li><%: Html.ActionLink("DENIED/CANCELED", "CanceledList", "Admin")%></li>
</ul>
</div>
作为内容注入的页面看起来像这样:
<table cellpadding="2" cellspacing="0" border="1">
<thead>
<tr>
<td>Event name</td><td>Private</td><td>Location</td><td>Start date</td>
<td>Duration</td><td>Asset</td><td>Contact name</td><td>Email</td><td>Phone</td>
</tr>
</thead>
<tbody>
<tr>
<td>Some event Name<input type="hidden" id="bookingId" value="1"></td>
<td>Yes</td>
<td>...</td>
...
</tr>
</tbody>
</table>
在放置选项卡小部件的父页面上,我尝试从表元素的正文中读取值。
$(document).ready(function () {
function initializeCanceledTab(tabPanel/**/) {
var tabRows = $(tabPanel).find("table tr");
tabRows.each(function (index, domEl) {
var id = $(this).find("input:hidden").val();
or
var id = $(this).find("#bookingId:hidden").val();
or
var id = $(this).find("input:has[type='hidden']").val();
});
});
我可以读取除隐藏字段中的值之外的所有值。 $(this) 是一个 tr 元素。检查它(innerHTML)表明那里没有隐藏输入。但是当页面渲染时firebug和IE开发工具显示隐藏输入。 有人遇到过这个问题吗?如果有人可以提供帮助,将不胜感激。谢谢。
I use jquery tabs widget and populate each tab panel with content from another aspx page.
Looks like this:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="tabs">
<ul>
<li><%: Html.ActionLink("PENDING", "PendingList", "Admin")%></li>
<li><%: Html.ActionLink("APPROVED", "ApprovedList", "Admin")%></li>
<li><%: Html.ActionLink("DENIED/CANCELED", "CanceledList", "Admin")%></li>
</ul>
</div>
The page that is injected as a content looks like this:
<table cellpadding="2" cellspacing="0" border="1">
<thead>
<tr>
<td>Event name</td><td>Private</td><td>Location</td><td>Start date</td>
<td>Duration</td><td>Asset</td><td>Contact name</td><td>Email</td><td>Phone</td>
</tr>
</thead>
<tbody>
<tr>
<td>Some event Name<input type="hidden" id="bookingId" value="1"></td>
<td>Yes</td>
<td>...</td>
...
</tr>
</tbody>
</table>
On parent page, where the tab widget was placed I try to read values from body of table elemnt.
$(document).ready(function () {
function initializeCanceledTab(tabPanel/**/) {
var tabRows = $(tabPanel).find("table tr");
tabRows.each(function (index, domEl) {
var id = $(this).find("input:hidden").val();
or
var id = $(this).find("#bookingId:hidden").val();
or
var id = $(this).find("input:has[type='hidden']").val();
});
});
i can read all values except value in a hidden field. $(this) is a tr element. Inspecting it (innerHTML) showed that there is no hidden input there. But when page rendered firebug and IE development tool show hidden input.
Did anybody meet this issue? Will be very appreciated if somebody can help. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道您是否仍然遇到问题,但假设内容已正确加载,这应该可以工作:
:hidden 与 :text 或 :button 不同 - http://api.jquery.com/hidden-selector/
Don't know if you're still having problems with this but this should work assuming the content has loaded correctly:
:hidden isn't the same as :text or :button - http://api.jquery.com/hidden-selector/