Append text to input field

后端 未结 6 1156
广开言路
广开言路 2020-11-28 05:38

I need to append some text to an input field...

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 06:10

    If you are planning to use appending more then once, you might want to write a function:

    //Append text to input element
    function jQ_append(id_of_input, text){
        var input_id = '#'+id_of_input;
        $(input_id).val($(input_id).val() + text);
    }
    

    After you can just call it:

    jQ_append('my_input_id', 'add this text');
    

提交回复
热议问题