How to create <input type=“text”/> dynamically

后端 未结 12 1070
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 10:47

I want to create an input type text in my web form dynamically. More specifically, I have a textfield where the user enters the number of desired text fields; I want the tex

12条回答
  •  忘掉有多难
    2020-12-02 11:38

    I think the following link will help you. If you want to generate fields dynamically and also want to remove them on the same time you can get the help from here. I had the same question, So i got the answer

    $(function() {
            var scntDiv = $('#p_scents');
            var i = $('#p_scents p').size() + 1;
    
            $('#addScnt').live('click', function() {
                    $('

    Remove

    ').appendTo(scntDiv); i++; return false; }); $('#remScnt').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); });

    http://jsfiddle.net/jaredwilli/tZPg4/4/

提交回复
热议问题