我需要取消设置 jQuery .toggle(odd,even) 的状态
我的表格单元格中有可以打开和关闭的项目。
外部按钮接受点击并通过 ajax 提交选定的单元格值。
问题是我想重置所选单元格的切换状态。
我可以轻松取消突出显示,但随后需要双击才能触发正确的切换。
.toggle(odd, Even) 可以通过外部调用重置或循环吗?
谢谢
I have items in a table cell that gets toggled on and off.
An external button accepts a click and submits the selected cell values via ajax.
The problem is that I want to reset the toggle state for the selected cells.
I can easily unset the highlighting, but then need a double click to trigger the correct toggle.
Can the .toggle(odd, even) be reset or cycled via an external call?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我没有测试过,但是可以这样做吗?
I have not tested but, could it be done like this?
我最终通过选择已经切换的元素列表解决了这个问题。
然后我调用 .click 。
这似乎是一个解决方法,但因为我无法触发切换状态。我就这样解决了。
I eventually solved this by selecting the already toggled list of elements.
I then call a .click on it.
Which seems like a bit of a workaround, but since I can't trigger the state of toggle. I settled for this.
.toggle()
与.show()
和.hide()
之间的交替相同,因此只需调用.show()
或.hide()
取决于所需的“重置”状态。如果您使用 .toggle() 循环处理程序,则只需取消绑定并重新绑定切换事件即可。
.toggle()
is the same as alternating between.show()
and.hide()
so just call.show()
or.hide()
depending on what the desired "reset" state is.if you are using
.toggle()
to cycle through handlers then just unbind and rebind the toggle event.