jQuery .attr('value', 'new_value') not working?

前端 未结 11 1945
面向向阳花
面向向阳花 2020-12-10 04:56

I am trying to dynamically change the actual HTML value attribute of an input using jQuery. Although using input.attr(\'value\', \'myNewVal\'); wor

11条回答
  •  无人及你
    2020-12-10 05:48

    Don't use .attr() to change the value, use .val(), which was made specifically for this purpose:

    input.val("new value");
    

提交回复
热议问题