点击链接如何更改引导主题

我想在单击该主题名称的链接时在引导主题之间切换 这是HTML

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport"
    content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=no">
  <title>Theme Changer</title>
  <meta name="description" content="" />
  <meta name="keywords" content="">
  <link id="theme" rel="stylesheet" href="css/bootstrap.css" />
</head>
<body>
    <nav class="navbar navbar-expand-sm bg-light navbar-light">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="#">Active</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#">Disabled</a>
        </li>
      </ul>
    </nav>
    <div class="row">
        <div class="col-md-6">
            <a id="Cyborg" href="" class="btn btn-block">Cyborg</a>
        </div>
        <div class="col-md-6">
            <a id="Lux" href="" class="btn btn-block">Lux</a>
        </div>
    </div>
         <footer>
            <p>Theme Changer</p>
        </footer>
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
  <script>
$(document).ready(function () {
    $('#Cyborg').click(function () {
        $('#theme').attr('href', 'css/bootstrapcyborg.css');
    });
    $('#Lux').click(function () {
        $('#theme').attr('href', 'css/bootstraplux.css');
    });
});
  </script>
</body>
</html>

I have created link for initial page load css and then on click of either of the link i am replacing original href attribute with i have assign in jquery. Can anybody suggest where i am going wrong.

评论