它只工作了几秒钟,然后 div 再次消失:
$(document).ready(function () {
$("#done").click(function () {
$('#txtname').replaceWith(function () {
return '<div>' + $(this).val() + '</div>';
});
});
你也可以使用ID
if this
不行
$("#done").click(function() {
$('#txtname').replaceWith(function() {
return '<div>' + $("#txtname").val() + '</div>';
});
});
如果上面不起作用,这里是另一个例子
$("#done").click(function() {
$('#txtname').replaceWith('<div>' + $("#txtname").val() + '</div>');
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)