且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在输入标签内显示div?

更新时间:2023-12-04 23:42:52

简短答案:您不能/不可以.但是你可以让自己看起来像个样子.

Short answer: You can't/don't. But you can give the appearance that you are.

更长的答案:示例

$(function(){    
    $("#inputtext").keypress(function(e){
        var valueofinput= $(this).val();
        if(e.which==13)
        {
            $('#inputtext').before('<span class="tag">' + valueofinput + '</span>');
            $('input').val('');
        }
    });
    $(document).on('click', '.tag', function(){
        $(this).remove();
    });
    $('.inputholder').click(function() { $('#inputtext').focus(); });
});