gpt4 book ai didi

javascript - 单击时将标题名称替换为下拉名称

转载 作者:行者123 更新时间:2023-11-28 14:28:12 25 4
gpt4 key购买 nike

这里我有一个下拉按钮,它在下拉列表中包含以下三个列表。当我单击下拉列表中的列表时,它必须将名称替换为下拉列表中的列表名称。帮我解决这个问题。提前致谢。这是 fiddle 链接 https://jsfiddle.net/e8bny3kv/

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<div class="container">
<h2>Dropdowns</h2>
<p>The .dropdown class is used to indicate a dropdown menu.</p>
<p>Use the .dropdown-menu class to actually build the dropdown menu.</p>
<p>To open the dropdown menu, use a button or a link with a class of .dropdown-toggle and data-toggle="dropdown".</p>
<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
<a class="dropdown-item" href="#">Link 3</a>
</div>
</div>
</div>

最佳答案

试试这个

`$('.dropdown-item').click(function() {
$('.dropdown-toggle').html($(this).html());
});`

关于javascript - 单击时将标题名称替换为下拉名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54437917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com