我不太确定你想做什么,但我可以帮助让警报正常工作。您基本上没有正确使用 jQuery“on”功能。
$('#thisNeedsToBeContainer').on('focusout', '#elemToBindEventTo', function (event)....
以下之一将满足您的需要:
当文本框离开时这将触发
$(document).ready(function () {
alert("hello");
$("#cca").on('focusout', 'label.control input', function (event) {
alert('I am pretty sure the text box changed');
event.preventDefault();
});
});
这,将火上浇油change
$(document).ready(function () {
alert("hello");
$("#cca").on('change', 'label.control input', function (event) {
alert('I am pretty sure the text box changed');
event.preventDefault();
});
});
这,将火上浇油keyup
当打字时
$(document).ready(function () {
alert("hello");
$("#cca").on('onkeyup', 'label.control input', function (event) {
alert('I am pretty sure the text box changed');
event.preventDefault();
});
});
请参阅演示JsFiddle
您还应该关闭您的输入:
<input class="" type="text" value="[Null]"/>