簡體   English   中英

簡單的jQuery slideToggle在任何瀏覽器中均不起作用

[英]Simple jquery slideToggle doesn't work in any browser

我的網站上有一個用於下拉面板的簡單jquery代碼。 我已經在標題中包含了jquery.js文件。 但這仍然行不通。 與版本有關嗎?

HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>Slide Panel</title>
        <script type="text/javascript" src="script.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="style.css"></link>
    </head>

    <body>
        <div class="panel">
            <br />
            <br />
            <p>Panel</p>
        </div>

        <p class="slide">
            <div class="pull-me">
                Slide Up/Down
            </div>
        </p>
    </body>
</html>

CSS:

body {
    margin:0 auto;
    padding:0;
    width:200px;
    text-align:center;
}
.pull-me{
    -webkit-box-shadow: 0 0 8px #FFD700;
    -moz-box-shadow: 0 0 8px #FFD700;
    box-shadow: 0 0 8px #FFD700;
    cursor:pointer;
}
.panel {
    background: #ffffbd;
    background-size:90% 90%;
    height:300px;
    display:none;
    font-family:garamond,times-new-roman,serif;
}
.panel p{
    text-align:center;
}
.slide {
    margin:0;
    padding:0;
    border-top:solid 2px #cc0000;
}
.pull-me {
    display:block;
    position:relative;
    right:-25px;
    width:150px;
    height:20px;
    font-family:arial,sans-serif;
    font-size:14px;
    color:#ffffff;
    background:#cc0000;
    text-decoration:none;
    -moz-border-bottom-left-radius:5px;
    -moz-border-bottom-right-radius:5px;
    border-bottom-left-radius:5px;
    border-bottom-right-radius:5px;
}
.pull-me p {
    text-align:center;
}

和jQuery:

$(document).ready(function(){
    $('.pull-me').click(function(){
        $('.panel').slideToggle('slow');
    });
});

提前致謝! :)

<!DOCTYPE html>
  <html>
  <head>
    <title>Slide Panel</title>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> <!-- Always first call the jQuery library -->
    <script src="script.js"></script> <!-- Then call your custom scripts -->

    <link rel="stylesheet" href="style.css">  <!-- Link tag is selfclosing don't put </link> at the end -->
  </head>

  <body>
    <div class="panel">
        <br />
        <br />
        <p>Panel</p>
    </div>

    <p class="slide">
        <div class="pull-me">
            Slide Up/Down
        </div>
    </p>
  </body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM