我正在尝试创建一个函数,当文本输入字段的值更改时,该函数将执行。单击表格单元格时,该字段的值会发生更改,而不是键入,也不会粘贴。我试过这样:
$("#kat").change(function(){ alert("Hello"); });
我有文本字段:
<input type="text" id="kat" value="0"/>
但它不工作。任何帮助?
解决方法
这是来自对jQuery文档页面的评论:
In older,pre-HTML5 browsers,“keyup” is definitely what you’re looking for.
In HTML5 there is a new event,“input”,which behaves exactly like you seem to think “change” should have behaved – in that it fires as soon as a key is pressed to enter information into a form.
$(‘element’).bind(‘input’,function);