在中继器中调用 JQuery 函数
Calling JQuery function inside repeater
在中继器中调用jquery函数.我想在单击链接按钮时切换div的问题.我认为在这种情况下不是第一个jquery函数使用。我认为还有div 和链接按钮之间表格中的探针.
function toggleMe() {
$(function () {
$('.toggler').on('click', function (ev) {
$(this).next('.dataContentSection').toggle();
});
});
}
<div id="repeater"><div class="dataContentSection">
<div>Name</div>
</div>
<table>
<tr>
<td>
<asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton>
<asp:Label ID="Label1" runat="server" Text="Welcome"></asp:Label>
</td>
</tr>
</table>
<div class="dataContentSection" style="display: none;">
<div>Address Line 1:</div>
<div>Address Line 2:</div>
<div>Address Line 3:</div>
</div>
<div class="dataContentSection">
<div>Name</div>
</div>
<table>
<tr>
<td>
<asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton>
<asp:Label ID="Label2" runat="server" Text="Welcome"></asp:Label>
</td>
</tr>
</table>
<div class="dataContentSection" style="display: none;">
<div>Address Line 1:</div>
<div>Address Line 2:</div>
<div>Address Line 3:</div>
</div>
<div class="dataContentSection">
<div>Name</div>
</div>
<table>
<tr>
<td>
<asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton>
<asp:Label ID="Label3" runat="server" Text="Welcome"></asp:Label>
</td>
</tr>
</table>
<div class="dataContentSection" style="display: none;">
<div>Address Line 1:</div>
<div>Address Line 2:</div>
<div>Address Line 3:</div>
</div>
<div class="dataContentSection">
<div>Name</div>
</div>
<table>
<tr>
<td>
<asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton>
<asp:Label ID="Label4" runat="server" Text="Welcome"></asp:Label>
</td>
</tr>
</table>
<div class="dataContentSection" style="display: none;">
<div>Address Line 1:</div>
<div>Address Line 2:</div>
<div>Address Line 3:</div>
</div>
<div class="dataContentSection">
<div>Name</div>
</div>
<table>
<tr>
<td>
<asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton>
<asp:Label ID="Label5" runat="server" Text="Welcome"></asp:Label>
</td>
</tr>
</table>
<div class="dataContentSection" style="display: none;">
<div>Address Line 1:</div>
<div>Address Line 2:</div>
<div>Address Line 3:</div>
</div>
</div>
问题是toggleMe()
函数。如果你想切换div,你需要做这样的事情:-
$(function () {
$('.toggler').click(function (ev) {
$(".dataContentSection").toggle();
$(this).next('.dataContentSection').toggle();
});
});
希望这有帮助。
相关文章:
- 是否有一个JS/jQuery函数可以获取某个类的每个元素的ID
- 如何在JQuery函数中定义一个值,然后调用另一个函数并使用该值
- 如何从jquery函数返回变量
- 如何将具有文本类型值的var放入jQuery函数中
- Jquery函数在错误的时间提交
- 锚链接无法使用.slideUp jquery函数
- 重新分解jQuery函数
- 如何在视图模型contet更新更新上调用Jquery函数
- 如何向这个javascript/jquery函数添加参数
- 添加类来触发jquery函数
- 更改智能表中的页面将停止JQuery函数的工作
- 使用每500ms运行一次的jquery函数是个好主意吗
- jQuery函数不能只在一个页面上工作
- 如何将jquery函数链接到vanilla选择器
- 仅在小型设备上调用jQuery函数
- 如何将jquery函数仅应用于大屏幕
- 奇怪的jquery函数行为
- Backbone listenTo不将jquery函数作为处理程序进行激发
- 在jquery函数内部设置来自jquery函数的var;t运行
- 从Jquery函数中获取一个变量