Question

Maybe I'm too ignorant, but I just can't find a way to load the Chosen plug-in into my html. I've seen previous questions and they load .js and .css files, but I don't find them in the new versions. How do I load it now?

Was it helpful?

Solution

Well, first you have to include the jQuery library, get it from here, then you'll have to add the chosen.js file, downloaded from here, and finally you have to turn your select HTML element into "chosen" element, your HTML code should look like this example:

<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/chosen.js"></script>
<script type="text/javascript">
 $(document).ready(function() {
   $("#element").chosen();
 });
</script>

This is the default usage of chosen.js, you can however specify many other option, but it is better to read the documentation.

Download the latest version of chosen.js from here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top