jQuery - Append a Value to a INPUT, keeping it a Comma Delimited list

后端 未结 4 851
Happy的楠姐
Happy的楠姐 2020-12-16 14:42

I have an input like follows:


I\'d like to be able to append a value to th

4条回答
  •  庸人自扰
    2020-12-16 14:52

    Just add a conditional when you add the value to the field.

    var cur_val = $('#attachment-uuids').val();
    if(cur_val)
      $('#attachment-uuids').val(cur_val + "," + new_val);
    else
      $('#attachment-uuids').val(new_val);
    

提交回复
热议问题