jQueryUI autocomplete creates a ul list similar to the following. How do I select the ul list using jQuery or CSS? I could do ul.ui-autocomplete, however, I don't want to select every list of this class on my page but just one specific one. The IDs (i.e. ui-id-1) are generated by the plugin, so I can't use these. I thought maybe the open event would give me access, however, doesn't appear to be the case. addClass() adds the class to the input and not the ul
<ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" tabindex="0" style="display: none; width: 140px; top: 30px; left: 8px;">
<li class="ui-menu-item" id="ui-id-2" tabindex="-1">an apple</li>
<li class="ui-menu-item" id="ui-id-3" tabindex="-1">a peach</li>
<li class="ui-menu-item" id="ui-id-4" tabindex="-1">an orange</li>
</ul>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Testing</title>
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/ui-lightness/jquery-ui.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#autocomplete").autocomplete({
source: ["an apple","a peach","an orange"],
minLength: 1,
open: function( event, ui ) {
console.log('open',event,ui,this);
}
}).addClass( "whatever" );
$( "#autocomplete" ).on( "autocompleteopen", function( event, ui ) {console.log('autocompleteopen',event,ui,this);} );
});
</script>
</head>
<body>
<input type="text" id="autocomplete" />
</body>
</html>
li(an orange) either using CSS'slast-childor something similar using jQuery. Probably is I can't get ahold of theulelement.nth-child, like this.someclass ul li:nth-child(5), that 5 in bracket you need to change to the exact position.