[英]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.