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>
On the click event, call
$( "#tags" ).autocomplete( "close" );.Here is how I’d do it…
jsFiddle.