I have been trying to do this forever now but i didnt know how. Basically i have this code below that generates li elements and append them to an already existing ul.
$(document.body).on("keyup", "", ".menuSearch", function (e) {
if (e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40) {
$(".searchResults").html("");
var searchField = $(".menuSearch").val();
var expression = new RegExp(searchField, "i");
HidingShowingUlForSearch();
$.each(finalJsonForMenu, function (key, value) {
if (value.title.search(expression) != -1 || value.description.search(expression) != -1) {
$("#searchResults").append(
'<li class="list-group-item mickyMouseResultLi" style=" border:none; min-width: 95%;">' +
'<a target="_blank" href="' + value.url + '"</a>' +
'<p>' +
value.title + '</p>' + '</li>');
//+'<p style="color: #757373">' + value.description + '</p>'
}
});
}
});
this is the generated HTML by this code:
<ul class="list-group searchResults pre-scrollable mickyMouseUl" style="position: absolute; z-index: 13; border: 1px solid rgb(206, 206, 206); display: block;" id="searchResults">
<li class="list-group-item mickyMouseResultLi" tabindex="1" style=" border:none; min-width: 95%;">
<a target="_blank" href="testlink" <="" a="">
<p>APU/APIIT PAGOL</p>
</a>
</li>
<li class="list-group-item mickyMouseResultLi" tabindex="2" style=" border:none; min-width: 95%;">
<a target="_blank" href="testlink" <="" a="">
<p>APU B.Sc. Presentations</p>
</a>
</li>
<li class="list-group-item mickyMouseResultLi" tabindex="3" style=" border:none; min-width: 95%;">
<a target="_blank" href="testlink" <="" a="">
<p>APU Parking Guideline</p>
</a>
</li>
<li class="list-group-item mickyMouseResultLi" tabindex="4" style=" border:none; min-width: 95%;">
<a target="_blank" href="testlink" <="" a="">
<p>APU Documents</p>
</a>
</li>
<li class="list-group-item mickyMouseResultLi" tabindex="5" style=" border:none; min-width: 95%;">
<a target="_blank" href="testlink" <="" a="">
<p>APU Student Handbook</p>
</a>
</li>
<li class="list-group-item mickyMouseResultLi" tabindex="6" style=" border:none; min-width: 95%;">
<a target="_blank" href="testlink" <="" a="">
<p>APU B.Sc Presentations & EOS Interview/LCM Schedules - Management Console</p>
</a>
</li>
<li class="list-group-item mickyMouseResultLi" tabindex="7" style=" border:none; min-width: 95%;">
<a target="_blank" href="testlink" <="" a="">
<p>APU B.Sc Presentations & EOS Interview/LCM Schedules</p>
</a>
</li>
</ul>
now thats great its working the way I want it too but then after the li generates i have to use the courser to point and click on them, while I need a way that i can just use the arrow keys with the enter button to access the newly generated li's. any suggestions?