代码可在jsFiddle中使用,但不能在浏览器中使用 [英] Code working in jsFiddle but not in browser

查看:77
本文介绍了代码可在jsFiddle中使用,但不能在浏览器中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行以下代码,这些代码是在本地计算机上编写的:

I'm trying to run the following code, written on my local machine:

http://www.jsfiddle.net/WShdx/3/

从功能角度(忽略上一个和下一个按钮中损坏的图像以及大小错误的主图像),单击/悬停功能在jsfiddle中正常运行.但是,在我的本地计算机上,它根本无法工作.

Functionality-wise (ignore the broken images in the previous and next buttons, and the wrongly-sized main images) the click/hover function is working properly in jsfiddle. However, on my local machine it's not working at all.

对于所有意图和目的,代码是相同的,除了本地副本具有此head部分以加载到jsfiddle页面中包含的javascript/css文件中之外:

For all intents and purposes the code is identical, except the local copy has this head section to load in the javascript/css files that are contained within the jsfiddle page:

<head>
  <title>Jquery Wizard</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  <script src="wizard.js" type="text/javascript" ></script>
</head>

jsFiddle是否有一些出色的功能可以使我的代码神奇地工作,还是我在这里错过了一些东西?

Is there some wonderful function of jsFiddle that is making my code magically work, or am I missing something here?

推荐答案

您选择在jsFiddle上运行脚本代码"onload",即有所不同.

You chose to run the script-code "onload" on jsFiddle, that's the difference.

没有加载就不会找到$('area'),因为您的脚本位于<head>内,而<body>内的元素仍然是未知的.

Without onload it will not find $('area') , because your script is placed inside the <head>, where the elements inside the <body> are still unknown.

这篇关于代码可在jsFiddle中使用,但不能在浏览器中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆