I try using Selectric to select the current (selected) element LI, but nothing works, tell me who knows how to do it

There is one catch, I use not SELECT and OPTION, but UL and LI: Example Selectric and ul, what I am doing here

Here is a link to Selectric http://lcdsantos.imtqy.com/jQuery-Selectric/index.html

  • Please show your code. How is li chosen? Maybe you can do what you want without this library - apelsinka223

1 answer 1

I found a similar solution, here's the HTML:

<ul class="customOptions"> <li class="">Select something</li> <li class=""><span data-value="value1"> Choice 1</span></li> <li class="selected"><span data-value="value2"> Choice 2</span></li> <li class=""><span data-value="value2"> Choice 3</span></li> </ul> 

JS will look like this:

 $(function(){ $('.customOptions').selectric({ maxHeight: 300, onChange: function(element) { alert( $('.selectricItems').find('.selected span').attr('data-value') ); } }); }); 

Reference to the source: https://stackoverflow.com/questions/25137198/magento-javascript-undefined-is-not-a-function-jquery-selectric