为什么来电console.log(this.attr("id"));
未定义?
(function( $ ) {
$.fn.fs_suggest = function(options) {
console.log(this.attr("id"));
};
})( jQuery );
$("#places_search").fs_suggest();
这是HTML:
<div class="search_container" id="search">
<form data-remote="false" method="get" action="/search">
<input type="text" placeholder="search places" name="query" id="places_search">
<input type="submit" value="search">
</form>
</div>
我正在尝试获取对调用 .fs_suggest() 函数的元素的引用,在本例中为 $("#places_search")