它只工作了几秒钟,然后 div 再次消失:
$(document).ready(function () {
$("#done").click(function () {
$('#txtname').replaceWith(function () {
return '<div>' + $(this).val() + '</div>';
});
});
它只工作了几秒钟,然后 div 再次消失:
$(document).ready(function () {
$("#done").click(function () {
$('#txtname').replaceWith(function () {
return '<div>' + $(this).val() + '</div>';
});
});
ID
如果this
不起作用,您也可以使用
$("#done").click(function() {
$('#txtname').replaceWith(function() {
return '<div>' + $("#txtname").val() + '</div>';
});
});
如果上述方法不起作用,这是另一个示例
$("#done").click(function() {
$('#txtname').replaceWith('<div>' + $("#txtname").val() + '</div>');
});