如何在java脚本中编写html结构,
<table>
<tr>
<td>
<form>
<input type="file"></input></td>
<td><input type="submit"></input></td>
</form>
</table>
最佳答案
尝试使用以下内容并将其添加到 html
标记末尾之前。
<script>
var myForm = document.createElement("form");
myForm .setAttribute('method',"post");
myForm .setAttribute('action',"submit.php");
var myInput = document.createElement("input");
myInput .setAttribute('type',"file");
myInput .setAttribute('name',"somename");
var formSubmit = document.createElement("input");
formSubmit.setAttribute('type',"submit");
formSubmit.setAttribute('value',"Submit");
myForm .appendChild(myInput);
myForm .appendChild(formSubmit);
document.getElementsByTagName('body')[0].appendChild(myForm);
</script>
关于javascript - 如何用javascript编写html结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36215372/