简体   繁体   English

无法使用jQuery隐藏div元素

[英]Unable to hide div element using Jquery

In my code i am trying to hide a div element which contains a image, but when i run the code i get - ReferenceError: jQuery is not defined })( jQuery ); 在我的代码中,我试图隐藏一个包含图像的div元素,但是当我运行代码时,我得到了-ReferenceError:jQuery未定义})(jQuery); in the file jquery-ui.js (line 314). 在文件jquery-ui.js中(第314行)。 My code is given below 我的代码如下

<!DOCTYPE html>
<html>
<head>
    <title>Sliding a div</title>
    <script type="text/javascript" src="plugin/ui/jquery-ui.js"></script>
    <script type="text/javascript" src="plugin/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#1').click(function(){
                console.log("i am inside");
                $('#element').hide('slide',{direction:'left'},1000);
            });
        });
    </script>
</head>
<body>
<div id="headder" style="width: 1300px; height: 100px">
    <h1>Slide the div</h1>
</div>
<div id="element" style="width: 600px; height: 400px; border: 2px solid red; position: relative">
    <img src="images/aa.jpg" width="600" height="400">
</div>
<div id="control" style="position: relative">
    <input type="button" id="1" value="PRESS">
</div>
</body>
</html>

Please let me know the reason behind this. 请让我知道其背后的原因。

You need to reference jQuery before jQuery UI: 您需要 jQuery UI 之前引用jQuery:

<script type="text/javascript" src="plugin/jquery-1.9.1.js"></script>
<script type="text/javascript" src="plugin/ui/jquery-ui.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM