我有一个jQuery自动填充设置,从一个下拉式<select>
标签。它的工作很好,但我有一个问题;当用户选择'autofill
'建议中的一个时,我试图简单地将.show();
指定为div; 即。从我的下拉列表中选择。我迄今为止的所有努力都失败了,我一直在检查在dev控制台中输出的选择器并在JS中添加点击功能到.show();
我的div,但是没有任何内容正在被读取,我想象这是由于z-index
问题或某事关于jQuery如何为自动填充渲染select > ul > li
元素。无论如何,我有什么建议可以实现这个目标?下拉选择与jQuery自动填充>选择.show(); div
即。上面是一个截图,一次,说'科罗拉多'被选中,或'点击'.show();
股利。
我尝试看起来像(with attempted use of various selectors)
$('input').click(function(event) {
$(".state_overlay").show();
// $('li.ui-menu-item').innerhtml().append.$("h2.statename"); /* edit */
});
我的jQuery基地自动填充代码...
$.widget("app.autocomplete", $.ui.autocomplete, {
_create: function() {
if(this.element.is("select")) {
var self = this;
this.original = this.element.hide();
this.element = $("<input/>").insertAfter(this.original);
this.options.source = function(request, response) {
var filter = $.ui.autocomplete.filter,
$options = self.original.find("option"),
result = $options.map(function() {
return $(this).html();
});
response(filter(result, request.term));
};
}
this._super("_create");
},
_destroy: function() {
this._super("_destroy");
this.element.remove();
this.original.show();
}
});
$(function() {
$("#autocomplete").autocomplete();
});
我加价看起来是这样的:
<select id="autocomplete" class="autocomplete">
<option value="">Select State</option>
<option value="AL">Alabama</option>