If jQuery's toggle()
is used on a <div>
containing form elements, will those form elements get submitted with the form, even though they are hidden?
My code (though probably not needed for this particular question):
$('.cms_loop_title').click(function(){
$ctg = $(this).attr('rel');
$('.'+$ctg).toggle();
//ale开发者_如何学编程rt($ctg);
});
Yes, they'll get submitted unless they are removed from the document or have the disabled
attribute set on them.
For more information, see the HTML5 Working Draft — Section 4.10.22.4 Constructing the form data set. The information there is more-or-less the same as previous HTML versions.
In order to prevent submitting, you have to disable the elements. Hiding doesn't do the trick (I had the same issue a while ago)
精彩评论