过去两个晚上,我在下面的代码中挣扎。问题是我需要记住展开(或)折叠的切换部分,并且在页面重新加载时我已经将它们显示为展开(或)折叠。
$(function() {
$('tr.subCategory')
.css("cursor", "pointer")
.attr("title", "Click to expand/collapse")
.click(function() {
$(this).siblings('.RegText').toggle();
});
$('tr[@class^=RegText]').hide().children('td');
})
我在这样的另一个论坛中找到了小解决方案。以逗号分隔值在隐藏字段中存储“.subCategory”id 值。
In Asp.net page:
<input id="myVisibleRows" type="hidden" value="<% response.write(myVisibleRowsSavedValue) %" />
In .js:
var idsStr = $(#myVisibleRows).val();
现在我的问题是:单击切换时如何在隐藏字段中存储多个值(.subCategory id)?还如何解析它们并迭代它们获取ID并显示切换?我对 jQuery 非常陌生。请有人帮我解决这个问题。