【发布时间】:2012-01-23 07:27:00
【问题描述】:
我在 change_form.html 中有很多字段集。基于单击功能,我希望隐藏/显示一些字段集。如何获取字段集 ID?有超过 1 个字段集。
在 JavaScript 中 例如。 $('fieldset')[1].hidden =true; //根据某些条件为假
我想要一个与上述语句等效的 django jQuery。
我试过了,$("#fieldset")1 = true; 也试过 $("div.form-row.field1.field2").hidden = true;
我只想使用 django.jQuery,如下所示。如何访问字段集 1、2 和显示/隐藏功能。
(function($){
$(document).ready(function($){
//function to hide/show the fieldset related to POP3_status
// if it is checked, show fieldset[1] and fieldset[2]
//if it is not checked, hide fieldset[1], fieldset[2]
$("#id_pop3_status").click(function(){
var checked = $("#id_pop3_status").is(':checked');
//not a POP3 account
if (!checked){
alert('not clicked');
$("#fieldset")[1].hide();
}
//if the POP3_status is checked i.e it is POP3 account
else {
alert('clicked');
$("#fieldset")[1].show();
}
});
});
})(django.jQuery);
【问题讨论】:
标签: jquery