我有以下脚本,只要#txtAllowSearch是平的HTML工作:自动完成和生活?
为#txtAllowSearch动态由JavaScript/jQuery的创建这便会立即停止工作。
我是否需要使用jqueries才能使其工作?
我有以下脚本,只要#txtAllowSearch是平的HTML工作:自动完成和生活?
为#txtAllowSearch动态由JavaScript/jQuery的创建这便会立即停止工作。
我是否需要使用jqueries才能使其工作?
jQuery.live现已弃用。
为了达到这个目标,您现在应该使用$(document).on。
$(document).ready(function(){
$(document).on("focus.autocomplete", "#txtAllowSearch", function() {
source: "test_array.aspx",
delay: 0,
select: function (event, ui) {
$("#txtAllowSearch").val(ui.item.value); // display the selected text
$("#txtAllowSearchID").val(ui.item.id); // save selected id to hidden input
}
});
});
欲了解更多信息,请参阅jQuery的API文档:http://api.jquery.com/on/
或许是肯定的,如果#txtAllowSearch是被动态创建并插入我的DOM – Rafay 2011-01-31 09:33:51