change event not working for a textbox when the value is assigned externally

后端 未结 6 1805
臣服心动
臣服心动 2021-01-22 17:14

I have a textbox and a button. When I click the button, it sets certain value in the textbox. I want to submit the page whenever the value of the textbox is changed.

Ple

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-22 17:51

    you can achieve like

    $('.element').val('value').change(function(){
          $("#form").submit();
    }); 
    

    http://jsfiddle.net/senstar2/CHjL5/5/

提交回复
热议问题