javascript - Change value of single dropdown -
i have run problem , i'm not sure how around it. have 5 dropdown buttons, , when select 1 option first dropdown, changes option 5 dropdowns.
any appreciated :d (p.s. copied 1 block of code 1 button. note 5 dropdowns in same of modal).
the function i'm trying use update is
$(".dropdown-menu li a").click(function() { $("#communityone").text($(this).text()); $("#communityone").val($(this).text()); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="communityone" data-toggle="dropdown">choice 1 <span class="caret"></span> </button> <ul class="dropdown-menu" id="c11"> <div class="col-md-2"> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">speedrunner</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">giveaway</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">community</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">interactive</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">chill</a> </li> <p></p> </div> <div class="col-md-2"> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">beta</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">exampl</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">example</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">example</a> </li> <p></p> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">example</a> </li> <p></p> </div>
$("div.dropdown ul li").on("click",function() { $(this).parents(".dropdown").find("button").html($(this).text()+" <span class='caret'></span>"); });
Comments
Post a Comment