1

I want to use bootstrap dropdown menu, but problem is that i cant find how to change menu from list to be active?Any suggestion?

<li class="dropdown">
  <?php
    global $easy_translation_manager_plugin;
    $current_lang = $easy_translation_manager_plugin->selectede_lang;
  ?>
  <button class="btn btn-default dropdown-toggle" style="background-color:transparent;color:white;border-right:white;border-bottom:none;boder-left:none;border-top:none;font-weight:bold;" type="button" data-toggle="dropdown"><?php echo ($current_lang == 'en') ? 'EN' : 'BS'; ?>
  <span class="caret" style="color:red;"></span></button>
  <ul class="dropdown-menu">
    <li><a href="<?php echo $url=strtok($_SERVER["REQUEST_URI"],'?'); ?>?lang=<?php echo ($current_lang == 'en') ? 'bs' : 'en'; ?>"><?php echo ($current_lang == 'en') ? 'BS' : 'EN'; ?></a>
    </li>
  </ul>
</li>

1 Answer 1

2

Try something like this:

  $( document.body ).on( 'click', '.dropdown-menu li', function( event ) {

      var $target = $( event.currentTarget );

      $target.closest( 'li.dropdown' )
         .find( 'span' ).text( $target.text() )
            .end()
         .children( '.dropdown-toggle' ).dropdown( 'toggle' );

      return false;

   });

jsfiddle: http://jsfiddle.net/e0a1vooc/2/

Sign up to request clarification or add additional context in comments.

4 Comments

its not working... it not change language in dropdown menu again
you want a option to be selected as a default?
i want when user choose something from dropdown it display that as selected value...but when i add text in span i get that new value and old value also
w3schools.com/bootstrap/… thats how looks now...its not changing value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.