So, I have a simple UL page that needs to be populated at runtime through AJAX calls and JSON responses.
$(".select-brands").append("<li data-value=" + manufacturerName + ">" + manufacturer + "</li>");
After that, I use this data-value attribute to scroll to the element with the same name as the user selected in another selection field. Therefore, when they select a Harley Davidson picture, jQuery will look in the element with
data-value="HARLEY-DAVIDSON"
However, the result is not what I expected, instead of this data value I get such elements instead
<li data-value="HARLEY" davidson="">HARLEY DAVIDSON</li>
How can I make it so that I can select elements based on this name? can this be done through text inside li tags?
var listBrand = $('li[data-value="'+ selectedBrand.toUpperCase() +'"]');
var parent = $('#brands-select');
var index = listBrand.index();
parent.animate({
scrollTop: $('#brands-select li:nth-child('+ index +')').position().top - $('#brands-select li:first').position().top
}, 'slow');
To the code that I used to go to the item selected.