Bootstrap implements dropdown to select select option

https://www.cnblogs.com/zou1234/p/7884053.html#commentform

The example of the bootstrap official website is a bit pitted. It only gives you a drop-down and beautifies it, but you can't select it when you click the drop-down. This hurdle has already made a lot of people do not want to use its drop-down box.

But the native drop-down box is different in each browser, especially in IE, which is too ugly, so let’s not talk nonsense and go to the code directly;


<div id="addgroups" class="btn-group">
                <button type="button" data-name="" id="" class="btn btn-default">
                <i class="fa fa-plus">Add Groups</i>
                </button>
                <div class="btn-group">
                  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="">
                    <span class="buttonText"><i id="dropdownMenu2" class="fa fa-eye"></i></span>
                    <span class="caret"></span>
                  </button>
                  <ul class="dropdown-menu" role="menu">
                    <li>
                      <a href="#" onclick="shows1($(this).text())"><i class="fa fa-pencil">Full AccessRead</i></a>
                    </li>
                    <li>
                      <a href="#" onclick="shows1($(this).text())"><i class="fa fa-eye">Read Only</i></a>
                    </li>
                    <li>
                      <a href="#" onclick="shows1($(this).text())"><i class="fa fa-eye-slash">Deny Access</i></a>
                    </li>
                  </ul>
                </div>
              </div>

function shows1(a) {
      if (a=="Full AccessRead"){
        $("#dropdownMenu2").removeClass();
        $("#dropdownMenu2").addClass("fa fa-pencil");
      }else if(a=="Read Only"){
        $("#dropdownMenu2").removeClass();
        $("#dropdownMenu2").addClass("fa fa-eye");
      }else if(a=="Deny Access"){
        $("#dropdownMenu2").removeClass();
        $("#dropdownMenu2").addClass("fa fa-eye-slash");
      }
      // $('.buttonText').text(a)
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325532977&siteId=291194637