我试图在我的.js文件中将表单附加到我的文档正文中。我按下“继续”按钮,表格出现。表单在屏幕上正确显示,但输入字段不允许输入文本。
$(document).ready(function() {
$('body').append('<div id="checkout"><button id="checkout2">Proceed </button></div>');
$('#checkout').one('click', function(e) {
$('body').html(
'<div id="payarea"><h1 size="50"><u>Checkout</u> </h1></ br>' +
'<form method="post" action="nav.html" >' +
'<table width=518 border="0" cellpadding="0" cellspacing="0" >' +
'<tr> ' +
'<td height="22" colspan="3" align="center" ><strong>Billing Information </strong></td>' +
'</tr>'+
'<tr> '+
'<td height="22" width="180" align="right" >Full name:</td>'+
'<td colspan="2" align="left"><input type="text" size="50"></td>'+
'</tr>'+
'</table>'+
'<input id="payment1" type="submit" value="Send name">'+
'</form>'+
' </div>');
});
});
css。
input:not([type]) {
padding: 1px 0px;
}
user agent stylesheetinput {
-webkit-appearance: textfield;
padding: 1px;
background-color: white;
border: 2px inset;
border-image-source: initial;
border-image-slice: initial;
border-image-width: initial;
border-image-outset: initial;
border-image-repeat: initial;
-webkit-rtl-ordering: logical;
-webkit-user-select: text;
cursor: auto;
}
user agent stylesheetinput {
margin: 0em;
font: normal normal normal normal 13.3333330154419px/normal Arial;
text-rendering: auto;
color: initial;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
}
user agent stylesheetinput {
-webkit-writing-mode: horizontal-tb;
}
答案 0 :(得分:1)
我在jsfiddle中实现了您的代码。
<强> HTML 强>
<div id="checkout"><button id="checkout2">Proceed </button></div>
<强>的jQuery 强>
$(document).ready(function() {
$('#checkout').one('click', function(e) {
$('body').html(
'<div id="payarea"><h1 size="50"><u>Checkout</u> </h1></ br>' +
'<form method="post" action="nav.html" >' +
'<table width=518 border="0" cellpadding="0" cellspacing="0" >' +
'<tr> ' +
'<td height="22" colspan="3" align="center" ><strong>Billing Information </strong></td>' +
'</tr>'+
'<tr> '+
'<td height="22" width="180" align="right" >Full name:</td>'+
'<td colspan="2" align="left"><input type="text" size="50"></td>'+
'</tr>'+
'</table>'+
'<input id="payment1" type="submit" value="Send name">'+
'</form>'+
' </div>');
});
});
输入字段允许文本输入,因此没有问题,除非有其他代码使输入字段为只读或禁用。右键单击元素并使用 Inspect Element 查看字段属性。