search

Home  >  Q&A  >  body text

javascript - bootstrap如何通过选择下拉框把选择的值赋值给下拉框button?

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<!-- <link href="css/ejoy.css" rel="stylesheet" /> -->
<link href="http://libs.baidu.com/bootstrap/3.0.3/cs... rel="stylesheet">
<script src="http://libs.baidu.com/jquery/2.0.0/jquer...
<script src="http://libs.baidu.com/bootstrap/3.0.3/js...

</head>
<body>

<p class="mainmenu">

<p class="dropdown pull-right">
<button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

Dropdown trigger
<span class="caret"></span>

</button>
<ul class="dropdown-menu" aria-labelledby="dLabel" style="">

 <li tabindex="-1">aa</li>
 <li tabindex="-1">bb</li>
 <li tabindex="-1">cc</li>
 <li tabindex="-1">dd</li>

</ul>
</p>
</p>
</body>
</html>

比如当选中某项是 button的文本值等于选中项

伊谢尔伦伊谢尔伦2815 days ago1109

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-11 08:59:53

    https://jsfiddle.net/La5tnaqo/

    reply
    0
  • Cancelreply