![](/img/trans.png)
[英]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.