简体   繁体   English

在jsfiddle中工作,但在Dreamweaver中不工作

[英]Works in jsfiddle but it wont work in dreamweaver

I have read that I have to put back in the event handler for it to work in dreamweaver from JS Fiddle, I have put it back in and I it still wont work? 我读到我必须放回事件处理程序才能使其在JS Fiddle中的Dreamweaver中工作,我放回了它,但它仍然行不通吗? Here is the Demo: http://jsfiddle.net/EfLJJ/6/ 这是演示: http : //jsfiddle.net/EfLJJ/6/

Here is my JS Code: 这是我的JS代码:

$(document).ready(function() {
$(".list .fs1").bind({
    mouseenter:function(){
        $(".sublist").show();
    },
    mouseleave: function(){
        $(".sublist").hide();
    }
    });
});  

Add the jQuery library to your script. 将jQuery库添加到脚本中。

Put this code inside the <head> tags of your page: 将此代码放在页面的<head>标记内:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

In your html code inside head put this line of code in order to include the jQuery library: 在您头内的html代码中,将以下代码行包括在内以包含jQuery库:

<script src="//code.jquery.com/jquery-1.10.2.js"></script>

Otherwise will not be able to use it. 否则将无法使用它。

In jsfiddle this works in a different way. 在jsfiddle中,它以不同的方式工作。

Also, if you're using jQuery version 1.7 and above, I'd recommend you switch from using ".bind()" to ".on()" for as ".on()" is the preferred method according to the jquery website. 另外,如果您使用的是jQuery 1.7及更高版本,我建议您从使用“ .bind()”切换到“ .on()”,因为根据jQuery,“。on()”是首选方法网站。 Check out the difference between ".bind()", ".on()" and ".live()" for more info here, What's the difference between `on` and `live` or `bind`? 在此处查看“ .bind()”,“。on()”和“ .live()” 之间的区别以获取更多信息, `on`和`live`或`bind`有什么区别?

Problem solved! 问题解决了! To get it running in Dreamweaver you have to use the Javascript Script Tags 要使其在Dreamweaver中运行,您必须使用Javascript脚本标签

Javascript: 使用Javascript:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
        /* Your Code Here */
    </script>

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

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