Javascript 悬停时更改进度条跨距文本

Javascript 悬停时更改进度条跨距文本,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有两个正在折叠的选项卡,每个选项卡上显示5个进度条。我希望当用户将鼠标悬停在进度条上时,进度条百分比(例如“79%”)更改为显示等级(例如“B+”)。我怎样才能做到这一点 第二个问题:我想让每个选项卡折叠另一个选项卡,例如,当我选择“第1学期”时,我想隐藏“第2学期”,反之亦然。如果我关闭“第1学期”,我想让“第2学期”显示等等 代码 在进度条中添加两个元素,一个表示百分比,一个表示等级。然后默认情况下隐藏一个。然后根据父悬停切换可见性 .progress.progress bar>spa

我有两个正在折叠的选项卡,每个选项卡上显示5个进度条。我希望当用户将鼠标悬停在进度条上时,进度条百分比(例如“79%”)更改为显示等级(例如“B+”)。我怎样才能做到这一点

第二个问题:我想让每个选项卡折叠另一个选项卡,例如,当我选择“第1学期”时,我想隐藏“第2学期”,反之亦然。如果我关闭“第1学期”,我想让“第2学期”显示等等

代码


在进度条中添加两个元素,一个表示百分比,一个表示等级。然后默认情况下隐藏一个。然后根据父悬停切换可见性

.progress.progress bar>span{
位置:相对位置;
身高:100%;
}
.进度。进度条>span>*{
位置:绝对位置;
排名:0;
过渡:不透明度。3秒缓解;
}
.进步.成绩{
不透明度:0;
}
.进度:悬停。成绩{
不透明度:1;
}
.进度:悬停。百分比{
不透明度:0;
}

79%B+

如果这是一个静态站点(因为
aria valuenow
中填写的等级让我相信;它不是用JS设置的),为什么不直接将
title
属性设置为适当的等级?然后将为您完成悬停操作,因为浏览器在悬停时显示
title
。@matthew-e-brown,我可以这样做,尽管它看起来不太好看
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>



  <section id="education" style="background-color:whitesmoke;">
    <div class="container">
      <div class="row d-flex no-gutters">
        <div class="col-lg-12 mx-auto">
          <h2 style="text-align: center;"> Education </h2>
          <br>
          <br>
          <br>
          <div class="pull-left" style="color: rgba(0, 0, 0, 0.801);">
            <h3>BSc in Computing</h3>
            <br>
          </div>
          <div class="row">
            <br>
            <br>

            <div class="col-md-4 disabled">

              <div class="tu-icon">
                <a target="_blank" href="https://www.it-tallaght.ie/">
                  <img class="mx-auto mb-2" src="tudub.png" alt="about"
                    style="width: 100%; height: 100%; border:2px solid #000000">
                </a>
              </div>
            </div>


            <div class="col-md-8">

              <!--nav tabs-->
              <div class="tabs">
                <ul class="nav nav-tabs" role="tablist">
                  <li role="presentation" class="active">
                    <a href="#first" data-toggle="tab"> First Year </a>
                  </li>
                  <li role="presentation">
                    <a href="#second" data-toggle="tab"> Second Year </a>
                  </li>
                </ul>
              </div>
              <!--Start single tab content-->
              <div class="tab-content">

                <div class="service-box tab-pane fade in active row show" id="first">
                  <div class="contents">

                    <div class="section-title">
                      <br>
                      <h4 style="color: rgba(0, 0, 0, 0.801);"> First Year</h4>
                      <br>
                    </div>



                    <div class="col-md-8 animate-box">




                      <div class="panel-group" id="accordion">
                        <!--Collapse Semester 1-->
                        <div class="panel panel-default show">
                          <div class="panel-heading">
                            <h4 class="panel-title">
                              <a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Semester 1</a>
                            </h4>
                          </div>
                          <div id="collapse1" class="panel-collapse collapse in show">
                            <div class="panel-body">

                              <!--progress bars-->

                              <h5>Software Development B+</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="79"
                                  aria-valuemin="0" aria-valuemax="100" style="width:79%">
                                  <span>79%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Business Information Systems B</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="69"
                                  aria-valuemin="0" aria-valuemax="100" style="width:69%">
                                  <span>69%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Visual Design B-</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="59"
                                  aria-valuemin="0" aria-valuemax="100" style="width:59%">
                                  <span>59%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Systems Analysis B</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="69"
                                  aria-valuemin="0" aria-valuemax="100" style="width:69%">
                                  <span>69%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Statistics B</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="69"
                                  aria-valuemin="0" aria-valuemax="100" style="width:69%">
                                  <span>69%</span>
                                </div>
                              </div>
                              <br>



                            </div>
                          </div>
                        </div>

                        <!--Collapse Semester 2-->
                        <div class="panel panel-default">
                          <div class="panel-heading">
                            <h4 class="panel-title">
                              <a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Semester 2</a>
                            </h4>
                          </div>
                          <div id="collapse2" class="panel-collapse collapse">
                            <div class="panel-body">

                              <!--progress bars-->


                              <h5>Software Development 2 B</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="68"
                                  aria-valuemin="0" aria-valuemax="100" style="width:68%">
                                  <span>68%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Introduction to Operating Systems B</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="69"
                                  aria-valuemin="0" aria-valuemax="100" style="width:69%">
                                  <span>69%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Web and Datasbase Fundementals B-</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="59"
                                  aria-valuemin="0" aria-valuemax="100" style="width:59%">
                                  <span>59%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Discrete Mathematics B-</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="59"
                                  aria-valuemin="0" aria-valuemax="100" style="width:59%">
                                  <span>59%</span>
                                </div>
                              </div>
                              <br>
                              <h5>Systems Analysis 2 B</h5>
                              <div class="progress" style="width: 100%;">
                                <div class="progress-bar  color-1" role="progressbar" aria-valuenow="69"
                                  aria-valuemin="0" aria-valuemax="100" style="width:69%">
                                  <span>69%</span>
                                </div>
                              </div>
                              <br>


                            </div>
                          </div>
                        </div>

                      </div>






                    </div>
                  </div>
                </div>
                <!--End single tab content-->
                <!--Start single tab content-->
                <div class="service-box tab-pane fade in" id="second">
                  <div class="contents">

                    <div class="section-title">
                      <br>
                      <h3> Second Year</h3>
                      <br>
                    </div>

                    <div class="col-md-8 animate-box">
                      <div class="progress-wrap">
                        <h3>Java</h3>
                        <div class="progress" style="width: 100%;">
                          <div class="progress-bar color-1" role="progressbar" aria-valuenow="90" aria-valuemin="0"
                            aria-valuemax="100" style="width:90%">
                            <span>90%</span>
                          </div>
                        </div>
                      </div>
                      <br>

                      <div class="progress-wrap ftco-animate">
                        <h3>C#</h3>
                        <div class="progress">
                          <div class="progress-bar color-2" role="progressbar" aria-valuenow="85" aria-valuemin="0"
                            aria-valuemax="100" style="width:85%">
                            <span>85%</span>
                          </div>
                        </div>
                      </div>
                      <br>

                    </div>
                  </div>
                </div>
                <!--End single tab content-->



              </div>


            </div>

          </div>
        </div>
      </div>
    </div>
  </section>
section {
  padding: 150px 0;
}

header {
  padding: 156px 0 100px;
}

.it-icons a {
  display: inline-block;
  height: 3.5rem;
  width: 3.5rem;
  background-color: #4582EC;
  color: #fff !important;
  border-radius: 100%;
  text-align: center;
  font-size: 1.5rem;
  line-height: 3.5rem;
  margin-right: 1rem;
}

.it-icons a:hover {
  transform: scale(1.3) rotate(20deg);
  background-color: skyblue;
}

.tu-icon a:hover {
  transform: rotate(5deg);
}


.os-icons a {
  display: inline-block;
  height: 3.5rem;
  width: 3.5rem;
  background-color: #4582EC;
  color: #fff !important;
  border-radius: 100%;
  text-align: center;
  font-size: 1.5rem;
  line-height: 3.5rem;
  margin-right: 1rem;
}

.os-icons a:hover {
  transform: scale(1.3) rotate(20deg);
  background-color: skyblue;
}




.tabs .nav-tabs > li, .tabs .nav-pills > li {
  float: none;
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 5px;
}

.tabs .nav-tabs {
  text-align: center;
  border-bottom: 0;
  margin-bottom: 20px;
}

.tabs .nav-tabs li:not(:last-child) {
  margin-right: 10px;
}

.tabs .nav-tabs li a {
  text-transform: capitalize;
  font-size: 20px;
  padding: 10px 25px;
  border: 2px solid #4582EC;
  border-radius: 0;
  transition: all .3s ease;
  font-weight: 600;
  color: #4582EC;
  font-family: "Source Sans Pro", sans-serif;
}

.tabs .nav-tabs li a:hover {
  background: #4582EC;
  color: #fff;
  border: 2px solid #4582EC;
}

.tabs .nav-tabs li.active a {
  color: #fff;
  background: #4582EC;
  border: 2px solid #4582EC;
}

.service-box {
  position: relative;
  width: 100%;
}

.service-box .contents {
  margin-left: 30px;
}



.tab-content {
  position: relative;
  float: left;
  width: 100%;
  z-index: 99;
}

.service-box {
  position: relative;
  width: 100%;
}

.service-box .section-title h3 {
  position: relative;
  font-size: 32px;
  line-height: 42px;
  font-weight: 700;
  padding-bottom: 20px;
  margin-bottom: 45px;
  color: #000;
  text-transform: uppercase;
}

.service-box .section-title h3:before {
  position: absolute;
  left: 0px;
  content: '';
  bottom: 0px;
  background: #333333;
  height: 1px;
  width: 55px;
}