我有兩個按鈕可以顯示兩個不同的元素。當我點擊第一個按鈕FIRST
時顯示。當我點擊第二個按鈕SECOND
顯示,但FIRST
也是可見的。我想要發生的是當第二個按鈕被點擊時FIRST
應該隱藏並且應該顯示SECOND
。在引導中使用可摺疊
代碼:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Simple Collapsible</h2>
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#first">Simple collapsible</button>
<div id="first" class="collapse">
FIRST
</div>
<br>
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#second">Simple collapsible</button>
<div id="second" class="collapse">
SECOND
</div>
</div>
</body>
</html>
非常感謝。效果不錯 –
隨時隨地..快樂編碼.. :) –