Add class with jQuery in Magento2.

In this blog, We are going to learn how to add jQuery in Magento.

jQuery UI in Magento 2

Besides, there is a jQuery UI that extends the jQuery functionality with a set of add-ons to improve the UI, and add effects, widgets, and themes. The full list of available tools you can find in the official documentation.

Let’s see how to use jQuery UI in Magento 2. There are 4 ways how you can request the elements from the UI library. 

1) You can use this script:

<script>
    require([
        'jquery',
        jquery/ui
],
function ($) {
       $("#element_example").accordion();
    });
</script>

Add the bellow code in your file To addclass in your class.
<script>
require(['jquery'],function(){
jQuery(document).ready(function() {
jQuery(".nav-toggle").on("click", function(e){
      jQuery('.nav-sections').toggleClass('active');
  });
});
});
</script>

Thanks for reading our blog If you have any problems please leave your query in a comment box.

Thanks