我正在使用这个脚本:
$.fn.conditionize = function(options){
var settings = $.extend({
hideJS: true
}, options );
$.fn.showOrHide = function(listenTo, listenFor, $section) {
if ($(listenTo).is('select, input[type=text]') && $(listenTo).val() == listenFor ) {
$section.slideDown();
}
else if ($(listenTo + ":checked").val() == listenFor) {
$section.slideDown();
}
else {
$section.slideUp();
}
}
return this.each( function() {
var listenTo = "[name=" + $(this).data('cond-option') + "]";
var listenFor = $(this).data('cond-value');
var $section = $(this);
//Set up event listener
$(listenTo).on('change', function() {
$.fn.showOrHide(listenTo, listenFor, $section);
});
//If setting was chosen, hide everything first...
if (settings.hideJS) {
$(this).hide();
}
//Show based on current value on page load
$.fn.showOrHide(listenTo, listenFor, $section);
});
}
$('.conditional').conditionize();
$('.showhide').click(function() {
$('#target').toggle('slow');
});
显示/隐藏表单字段。在显示之后,如何将此必需属性添加到此最初隐藏的字段集中? IOW,这些字段只显示前一个问题的答案是&#34;是&#34;,但如果他们回答&#34; no。&#34; <我不想要这些字段。 / p>