简体   繁体   English

如何在javascript输入框中更改文本后立即调用函数

[英]How to call the function as soon as the text changes in input box in javascript

in vue I am writing a form, input box when text changes it updates the function setMessage 在Vue中,我正在编写一个表单,当文本更改时输入框会更新函数setMessage

<input type="text" v-model="test" v-on:change"setMessage">

but the problem is it only updates if I click somewhere outside the input box. 但是问题是,只有在输入框外的某处单击时,它才会更新。

I believe their might be something other than change event ! 我相信他们可能不是change事件!

您应该改用input事件:

<input type="text" v-model="test" v-on:input="setMessage">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 输入更改后,如何使用javascript调用函数? - how can i call a function with javascript as soon as the input changes? 一旦文本值输入发生变化,JavaScript onchange就会更新变量 - JavaScript onchange update variable as soon as text value input changes 在javascript中其他函数执行完成后,如何立即调用函数? - How to call a function soon after other function execution is completed in javascript? 如果同一类的任何文本输入中的值发生变化,如何调用函数? - How to call function if the value changes in any text input with same class? 输入更改值时如何在Javascript中调用函数? - How to call a function in Javascript when a input changes value? 如果文本框输入值发生变化,请验证该字段……但如果…… - If text box input value changes, validate the field… but if… Javascript 如何从JavaScript中的文本输入键调用功能? - How to call function from text input key press in javascript? 当隐藏的输入框的文本由外部jquery更改时,如何触发函数? - How can I trigger a function when the text of a hidden input box changes by an external jquery? 如何使用 HTML 文本框值作为 JavaScript 参数或变量并调用 JavaScript Z86408593C34AF7261F 值框? - How do I use an HTML text box value as a JavaScript parameter or variable and call the JavaScript Function with the text box value? 调用输入类型文本的函数-Javascript / PHP - Function that call input type text - Javascript / PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM