I have an autocomplete text input:
<script type="text/javascript">
$(function()
{
var availableTags = <?php
$id_list = array("Name 1", "Name 2", "Name 3");
echo json_encode($id_list); ?>;
$("#FacultyName").autocomplete(
{
source: availableTags,
autoFocus:true
});
</script>
<input type="text" id="FacultyName">
I want do some task when user select on the available tag.
Is there any function like onClick
or onChange
to do it?
Autcomplete has a select event for this
Try like this
$("#FacultyName").autocomplete({
source: availableTags,
autoFocus: true,
select: function(event, ui) {
alert("select");
}
})
jQuery has the .change() method. Here is the API documentation to help.