幻灯片菜单Javascript无效

时间:2015-09-29 10:02:50

标签: javascript jquery css menu slide

我一直在尝试使用jQuery创建一个滑动菜单,但我在第5行和第6行遇到了错误 - 未定义的函数。任何人都可以看到我的代码有什么问题吗?

 // jQuery(document).ready(function($) {
jQuery(function($) {
 "use strict";
    $(document).ready(function () {
        $nav_list = $('#nav_list');
        $menuLeft = $('.pushmenu-left');


        $nav_list.click(function () {
            $(this).toggleClass('active');
            $('.pushmenu-push').toggleClass('pushmenu-push-toright');
            $menuLeft.toggleClass('pushmenu-open');
        });
    });
});

这是HTML:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>DogHouse</title>


<script type="text/javascript" src="PushMenuJS.js"></script>

<link href="PushMenuCSS.css" rel="stylesheet" type="text/css">
</head>

<body class="pushmenu-push">
    <nav class="pushmenu pushmenu-left">
         <h3>Menu</h3>    
    </nav>
    <div class="container">
        <div class="main">
            <section class="buttonset">
                <div id="nav_list">Menu</div>
                <!-- End Content -->
        </div>
        <!-- End Main -->
    </div>
    <!-- End Container -->
        </body>
</html>

最后,这是CSS

.pushmenu a {
    display: block;
}
.pushmenu-left {
    left: -240px;
}
.pushmenu-left.pushmenu-open {
    left: 0;
}
.pushmenu-push {
    overflow-x: hidden;
    position: relative;
    left: 0;
}
.pushmenu-push-toright {
    left: 240px;
}
 .pushmenu, .pushmenu-push {
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    transition: all 0.3s ease;
}
nav-list.active {
    background-position: -33px top;
}

道歉,我知道我提供的太多了

由于

1 个答案:

答案 0 :(得分:2)

您正在使用严格模式。您不能仅通过为其指定值来创建全局变量。

您必须使用 let decodedData = NSData(base64EncodedString: base64String, options:NSDataBase64DecodingOptions.fromRaw(0)!) let decodedString = NSString(data: decodedData, encoding: NSUTF8StringEncoding) println(decodedString) // my plain data 声明它。由于您不需要变量的全局范围,因此只需在现有行前加var