简体   繁体   English

jsFiddle工作。 在网页上执行不是吗?

[英]jsFiddle works. Implementation on webpage doesn't?

This js fiddle runs with no errors or problems: 这个js小提琴运行没有错误或问题:

http://jsfiddle.net/3j45B/2/ http://jsfiddle.net/3j45B/2/

However, when embedded within http://www.zabb.co.uk/untitled6.html it does not work? 但是,当嵌入到http://www.zabb.co.uk/untitled6.html中时,它不起作用吗? Any suggestions please? 有什么建议吗?


EDIT: 编辑:

Further to your comments and suggestions below a solution has been found, thank you all: 除了以下您的意见和建议外,还找到了解决方案 ,谢谢大家:

$(document).ready(function() {

    $('.thumbnail2').click(function() {
        src = $(this).attr('src');
        if (src != $('.img').attr('src')) {
            $('.img').fadeOut(250, function() {
                $(this).attr('src', src).fadeIn(250);
            });
        }
    });

});​

Important bit to ensure event works is to wrap your jQuery code within: 确保事件有效的重要一点是将jQuery代码包装在以下内容中:

$(document).ready(function() {
    // ...
});​

See following link for further information regarding this function: 有关此功能的更多信息,请参见以下链接:
Introducing $(document).ready() 介绍$(document).ready()

Wrap your embedded script in a $(...) or $(document).ready(...) 将嵌入式脚本包装在$(...)$(document).ready(...)

jsfiddle did that for you (see the dropdown box on the left that says "onLoad"?). jsfiddle为您做到了(请参阅左侧显示“ onLoad”的下拉框)。

Nothing wrong with your code. 您的代码没有错。 But you probably forgot to include a plugin called Galleria, I get Galleria not defined. 但是您可能忘了包含一个名为Galleria的插件,但我未定义Galleria。

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

相关问题 jQuery ticker在jsfiddle中可用,但在.HTML中不起作用 - jQuery ticker works in jsfiddle, but it doesn't work in .HTML Bootstrap崩溃导航栏可在jsfiddle上使用,在实际网站上不可用 - Bootstrap collapse navbar works on jsfiddle, doesn't work on actual website JQuery脚本在JSFiddle中工作,但不在我自己的浏览器中 - JQuery script works in JSFiddle, but doesn't in my own browser 代码在jsfiddle中有效,但在我的网站上不起作用 - Code works in jsfiddle but doesn't work on my site 脚本适用于 jsfiddle 但不适用于我的网页 jquery - script works on jsfiddle but not in my webpage jquery 在页面上放置一个随机生成器脚本-它可以工作。 添加另一个具有不同名称的名称-不起作用 - Put a random generator script on page - it works. Add another one with different names - doesn't work FetchAPI 并行 API 调用,使用 for 循环制作 URL 数组不起作用,手动数组有效。 不明白为什么 - FetchAPI parallel API calls, making URL array with for loop doesn't work, manual array works. Can't understand why jsFiddle无法识别类? - jsFiddle doesn't recognize classes? jQuery 没有响应:JSFiddle? - jQuery doesn't respond: JSFiddle? 当我尝试暂停并在jsFiddle中播放时,我的代码可以工作,但在我的html页面中不起作用 - When I try pause and play in jsFiddle, my code works but it doesn't work in my html page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM