亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

js addClass not working
給我你的懷抱
給我你的懷抱 2017-06-12 09:26:20
0
4
1183

js addClass has no effect

<html>
  <head>
    <style type="text/css">
      html,body{margin:0;padding: 0;}
      .header{background-color: #ffe4c4;}
      .main{background-color: #bdb76b;}
      .footer{background-color: #ffc0cb;}

      /* 動(dòng)態(tài)為footer添加類fixed-bottom */
      .fixed-bottom {position: fixed;bottom: 0;width:100%;}
    </style>

    <script src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript">
      $(function(){
          function footerPosition(){
              $("footer").removeClass("fixed-bottom");
              var contentHeight = document.body.scrollHeight,//網(wǎng)頁(yè)正文全文高度
                  winHeight = window.innerHeight;//可視窗口高度,不包括瀏覽器頂部工具欄
              if(!(contentHeight > winHeight)){
                  //當(dāng)網(wǎng)頁(yè)正文高度小于可視窗口高度時(shí),為footer添加類fixed-bottom
                  $("footer").addClass("fixed-bottom");
              } else {
                  $("footer").removeClass("fixed-bottom");
              }
          }
          footerPosition();
          $(window).resize(footerPosition);
      });
    </script>
  </head>


  <body>
    <p class="header">header</p>
    <p class="main">main content</p>
    <p class="footer">footer</p>
  </body>
</html>

給我你的懷抱
給我你的懷抱

reply all(4)
習(xí)慣沉默

jquery selects elements. If it is a class, add a dot.

Preview: https://ityanxi.github.io/seg...

phpcn_u1582

$("footer").addClass("fixed-bottom"); No, it should be $(".footer").addClass("fixed-bottom")

左手右手慢動(dòng)作

Footer should use the class selector $(".footer")
Welcome to my website to learn more JavaScript knowledge: http://www.aizelasi.club/arch...

習(xí)慣沉默

Solved, thanks
JackHuang
crp205
Turner

It should be $(".footer").addClass("fixed-bottom")

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template