我的网页中有4个字段集。我需要让这些字段集在页面加载时展开,然后在点击时折叠。下面的代码在点击时可以正常工作。
我是jQuery的新手。在几种情况下,我需要折叠2个字段集并根据后面代码的条件或使用jquery扩展其他字段集。
如何根据条件扩展/折叠字段集?
我尝试直接使用字段集ID“部门”,
open: function (event, ui) {
$("#dates").on('scroll', function () {
var inp = $(this).find('input.hasDatepicker');
$('#ui-datepicker-div').css('top', inp.offset().top + inp.outerHeight());
});
},
beforeClose: function () {
$('#dates').off('scroll');
},
以上操作无效。
jQuery
$('#Departments').parent().toggleClass('collapsed');
样式表
function pageLoad() {
$('fieldset.Collapsible').each(function () {
var $fieldSet = $(this);
var $theLegend = $(this).find('> legend');
$theLegend.click(function () {
$(this).parent().toggleClass('collapsed');
});
});
答案 0 :(得分:0)
您可以使用更多的类来创建对其可见和隐藏的字段集的组,然后使用jQuery使用toggleClass。
List<String>