Jquery 自动完成关闭功能
我有一个 Jquery 自动完成菜单,底部有一个图像 - 添加了下面的代码。
有没有办法让 Jquery 自动完成菜单在我单击图片后关闭(消失)?
感谢您的帮助。
<script>
$(function() {
var availableTags = [
"new york, ny",
"new york city, ny",
"manhattan, ny",
"queens, ny",
"brooklyn, ny",
"bronx, ny",
"staten island, ny",
"kings county, ny",
"richmond county, ny",
"big apple, ny"
];
$( "#tags" ).autocomplete({
source: availableTags,
open: function (event, ui) {
var nyc="<img src=\"images/iloveny.jpg\" onclick=\"DoGood()\"/>";
$(this).autocomplete("widget").append(nyc);
},
});
});
</script>
I have a Jquery Autocomplete menu with an image at the bottom of it - added with the code below.
Is there a way to have Jquery Autocomplete menu close (disappear) after I click on the picture?
Thank you for your help.
<script>
$(function() {
var availableTags = [
"new york, ny",
"new york city, ny",
"manhattan, ny",
"queens, ny",
"brooklyn, ny",
"bronx, ny",
"staten island, ny",
"kings county, ny",
"richmond county, ny",
"big apple, ny"
];
$( "#tags" ).autocomplete({
source: availableTags,
open: function (event, ui) {
var nyc="<img src=\"images/iloveny.jpg\" onclick=\"DoGood()\"/>";
$(this).autocomplete("widget").append(nyc);
},
});
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在点击事件上,调用
$( "#tags" ).autocomplete( "close" );
。这是我的做法...
jsFiddle。
On the click event, call
$( "#tags" ).autocomplete( "close" );
.Here is how I'd do it...
jsFiddle.
我是这样做的:
Here's how I did it: