-3

Hello i have a problem i am using uikit to make a dropdown and i have some problems adding a data class after the css for example:

<div class="uk-dropdown"data-uk-dropdown></div>

What i need to add is the "data-uk-dropdown". I tried with some jquery but it only seems to add it next the uk-dropdown but not after the "".

what i tried to use :

jQuery(document).ready( function() {
      $( ".uk-navbar-nav .meny-item" ).addClass( "",'uk-data-dropdown' );
      } );

1 Answers1

0

I think you are trying to add data attribute not the data class. It can be easily done by. jQuery(document).ready( function() { $( ".uk-dropdown" ).attr( "data-uk-dropdown","{mode:'click'}" ); } );

The above code will add data-uk-dropdown="{mode:'click'}" attribute to all the dom element having class .uk-dropdown.

i.e. your output will be <div class="uk-dropdown" data-uk-dropdown="{mode:'click'}"></div>

Apurva Ojas
  • 331
  • 1
  • 5