var form = $('<form/>', {
action: 'SupportRequest',
method: 'POST',
name: 'myForm',
id: 'myForm'
}).appendTo('body');
我必须在创建表单时手动添加enctype="multipart/form-data"
,我该怎么做才能使上面的代码看起来像
<form class="hidden" id="myForm" mrthod="post" enctype = "multipart/form-data" action="myservlet">
还请告诉我如何手动制作class ='hidden'
答案 0 :(得分:0)
您可以将它们添加到您已提供的对象的参数中:
var form = $('<form/>', {
action: 'SupportRequest', // this should be 'myservlet' to match the HTML you gave
method: 'POST',
name: 'myForm',
id: 'myForm',
enctype: 'multipart/form-data',
class: 'hidden'
}).appendTo('body');
答案 1 :(得分:0)
您可以创建一个包含所有必要标记的字符串,并使用jQuery注入它。
var htmlForm = '<form class="hidden" id="myForm" mrthod="post" enctype = "multipart/form-data" action="myservlet">';
$("body").append(htmlForm);