运行 ❯
获取你
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <style> /* Style to reverse the caret icon from pointing downwards to upwards */ .caret.caret-up { border-top-width: 0; border-bottom: 4px solid #fff; } </style> </head> <body> <div class="container"> <h2>Change the caret symbol on dropdown</h2> <div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown <span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> </ul> </div> </div> <script> $(document).ready(function(){ $(".dropdown").on("hide.bs.dropdown", function(){ $(".btn").html('Dropdown <span class="caret"></span>'); }); $(".dropdown").on("show.bs.dropdown", function(){ $(".btn").html('Dropdown <span class="caret caret-up"></span>'); }); }); </script> </body> </html>