选择事件上的自动完成文本输入

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">

Output:
enter image description here

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.

https://api.jquery.com/change/