在for循环中创建的元素上使用jquery函数(Using jquery function on elements created in a for | 您所在的位置:网站首页 › element中el-button存在重复点击 › 在for循环中创建的元素上使用jquery函数(Using jquery function on elements created in a for |
我使用此代码创建了几个包含数据的网格: @foreach(var set in viewModelEnvironment.SystemEnvironmentVariabelSets) { //Creating the grids for each set here... }这会创建一堆带有附加按钮的隐藏“面板”。 当点击其中一个按钮时,我希望相应的面板展开。 如果使用此代码仅使用一个面板,则此功能正常: $(".btn-slide").click(function () { $("#panelToHide").slideToggle("slow"); $(this).toggleClass("active"); return false; });如何在for循环中创建的每个唯一面板和按钮上使用.click功能? 如何为for循环中的每个元素赋予唯一标识符并更改jquery函数.click以单独对应每个元素? 谢谢 Im creating several grids with data using this code: @foreach(var set in viewModelEnvironment.SystemEnvironmentVariabelSets) { //Creating the grids for each set here... }This creates a bunch of hidden "panels" with attached buttons. When clicking on one of these buttons I want the corresponding panel to expand. This is working if just one panel exxits by using this code: $(".btn-slide").click(function () { $("#panelToHide").slideToggle("slow"); $(this).toggleClass("active"); return false; });How can I use .click function on each unique panel and button that is created in the for-loop? How can i give each element in the for-loop a unique identifier and change the jquery function .click to correspond to each element individually? Thanks |
CopyRight 2018-2019 实验室设备网 版权所有 |