数秒間だけ機能し、その後 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>');
});