Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I tried this, but nothing happens when I modify the input. Any idea?
<input type="text" id="date"> <script type="text/javascript"> $('#date').change(function () { alert('Date changed'); }); </script>
只有在文本框失去焦点时才会触发更改事件,因此您还应该使用 keyup 事件。此外,您使用“#date”,但由于“date”是您的文本框的类,您应该使用“.date”。
$('.date').change(function () { alert('Date changed'); }).keyup(function(){$(this).change()});
因为你用过#而不是.
#
.
$('.date')