1

数秒間だけ機能し、その後 div が再び消えます。

$(document).ready(function () {

    $("#done").click(function () {
        $('#txtname').replaceWith(function () {

            return '<div>' + $(this).val() + '</div>';
        });
    });
4

1 に答える 1

0

うまくいかないID場合にも使用できますthis

$("#done").click(function() {
    $('#txtname').replaceWith(function() {

        return '<div>' + $("#txtname").val() + '</div>';
    });
});

上記が機能しない場合の別の例を次に示します

$("#done").click(function() {
    $('#txtname').replaceWith('<div>' + $("#txtname").val() + '</div>');
});
于 2012-09-23T11:29:56.527 に答える