Can't get $(this) working in jQueryUI autocomplete

后端 未结 5 1498
滥情空心
滥情空心 2020-12-25 11:21

I\'m trying to create a generic autocomplete script using jQueryUI. The autocomplete should work for every:



        
5条回答
  •  难免孤独
    2020-12-25 12:05

    To access that input element you should be able to do the following:

    $(this.element).val();
    

    Of course, that just gets the value. You can access the other attributes like so:

    $(this.element).attr('value'); // just another way to get the value
    $(this.element).attr('id');
    

    Also, suppose you want to access that element in the select event, you can do that like so:

    $(event.target).attr('value');
    $(event.target).attr('id');
    

提交回复
热议问题