【发布时间】:2013-07-07 17:53:22
【问题描述】:
我有以下基本结构。我需要能够单独切换每个表的可见性。类似乎不起作用,因为它会用同一个类切换所有。项目数量未知,因此外部 div 数量未知,并且我不知道 id,因为它不是唯一的。
<div data-bind="foreach: items">
// Other pieces of data here...
<button data-bind="click: myToggleFunction">Hide/Show</button> // This could be image, link or whatever to trigger toggle
<table> // Need to toggle tables individually
//Rows and columns here bound to the elements of each "item"
</table>
</div>
只是不确定如何让它确定它试图切换哪个表。
【问题讨论】:
-
“我不知道 id 因为它不是唯一的”?那个怎么样?所有 id 必须是唯一的。
标签: jquery knockout.js