将对话框中的值追加到 HTML 正文



我在将对话框中文本框中的值附加到我的 html 正文时遇到问题。

<div id="dialog-form">
<form>
<label for="name">Name</label>
<input type="text" name="name" id="txt2 codein" class="text ui-widget-content ui-corner-all" />
</form>
</div>
<p>Please are you <span id="addname"></span>
setTimeout( function() {
$( "#dialog-form" ).dialog({
modal: true,
draggable: false,
height: 300,
width: 500,
open: function () {
$('body').addClass('stop-scrolling');
},
});
},4000);
var keeptrying = function(e) {
var addmust = $('#dialog-form #codein').val();
$("#addname").append("#dialog-form #codein");
}

任何帮助和答案都值得赞赏,谢谢

在这里,您可以使用解决方案 https://jsfiddle.net/g9m1pqmu/

setTimeout( function() {
$( "#dialog-form" ).dialog({
modal: true,
draggable: false,
height: 300,
width: 500,
open: function () {
$('body').addClass('stop-scrolling');
}
});
},4000);
$('#codein').keypress(function() {
$("#addname").html($('#codein').val());
});

我想这就是你要找的。

最新更新