[英]How do I perform a jQuery function on an element after it has been inserted into the DOM?
[英]How do I reference the sepcific object/dom element that an jquery-ui autocomplete function belongs to, when it has been applied to all inputs
$("input[type=text]").autocomplete({
minLength: 3,
source: function (request, response) {
alert( $(this).val() );
我有3个不同的输入文本框,但是$(this).attr("id")
或this.id
都返回未定义
不知道什么是可用的内source
关于this
。 您始终可以将其记录到控制台以查看返回的内容。 以下模式有助于在许多元素上实现插件
$("input[type=text]").each(function() {
var id = this.id;
$(this).autocomplete({
minLength: 3,
source: function(request, response) {
alert(id);
}
});
});
alert( $(this.element).attr("id") );
作品。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.