开发者

Do hidden form elements get submitted?

开发者 https://www.devze.com 2023-04-13 08:36 出处:网络
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?

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号