相同的代码在jsfiddle但不会在我的服务器上运行?

编程入门 行业动态 更新时间:2024-10-27 16:23:58
本文介绍了相同的代码在jsfiddle但不会在我的服务器上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我很困惑。我只是试图测试一个jquery(simpleselect),并得到它的工作正常jquery,但然后当我上传到我的服务器...完全不工作!我发布了相同的代码,但也许新鲜的眼睛可以帮助。

I'm so confused. I'm just trying to test out a jquery (simpleselect) and got it working fine on jquery, but then when I upload it to my server... totally doesn't work! I swear its the same code but maybe fresh eyes can help. What am I missing here?

这是我上传的代码:

<html> <head> <link rel="stylesheet" type="text/css" href="smartieparts/bootstrap/includes/templates/bootstrap/css/stylesheet_jquery.simpleselect.min.css" /> <script type="text/javascript" src="ajax.googleapis/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script type="text/javascript" src="smartieparts/bootstrap/includes/templates/bootstrap/jscript/jscript_jquery.simpleselect.min.js"></script> <script type="text/javascript"> $("#currency-select").simpleselect({ fadingDuration: 500, containerMargin: 100, displayContainerInside: "document" }); </script> </head> <body id="indexHomeBody"> <select name="currency" id="currency-select"> <option value="USD">USD</option> <option value="EUR">EUR</option> <option value="GBP">GBP</option> <option value="CAD">CAD</option> <option value="AUD">AUD</option> <option value="CHF">CHF</option> <option value="CZK">CZK</option> <option value="DKK">DKK</option> <option value="HKD">HKD</option> <option value="JPY">JPY</option> <option value="NZD">NZD</option> <option value="NOK">NOK</option> <option value="PLN">PLN</option> <option value="SGD" selected="selected">SGD</option> <option value="SEK">SEK</option> <option value="ILS">ILS</option> <option value="MXN">MXN</option> <option value="TWD">TWD</option> <option value="PHP">PHP</option> <option value="THB">THB</option> </select> </body> </html>

这里是 JSfiddle

请注意,JSfiddle有外部css和js资源,我从上面的代码复制/粘贴。

Note that the JSfiddle has external css and js resources that I exactly copy/pasted from the code above.

在JSfiddle页面上,下拉列表格式化并具有淡入淡出效果。在我的服务器上,它有些格式化,没有褪色。

On the JSfiddle page, the drop down is formatted and has a fade effect. On my server, it is somewhat formatted and has no fade.

我已将文件上传到我的服务器,以便您可以检查。 链接

I've uploaded the file to my server so you can check. Link

推荐答案

参考

在文档准备就绪之前,无法安全操作页面。 jQuery检测到这个准备状态为你。包含在 $(document).ready()中的代码只会在页面文档对象模型(DOM)准备好执行JavaScript代码时运行。包含在 $(window).load(function(){...})中的代码将会运行一次整个页面(图片或iframe),而不仅仅是DOM准备。

A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside $( window ).load(function() { ... }) will run once the entire page (images or iframes), not just the DOM, is ready.

将您的代码包装在文档就绪处理程序。

Wrap your code in document-ready handler.

指定一个函数以便在DOM完全加载时执行。

Specify a function to execute when the DOM is fully loaded.

<script> $(function() { // Handler for .ready() called. $("#currency-select").simpleselect({ fadingDuration: 500, containerMargin: 100, displayContainerInside: "document" }); }); </script>

更多推荐

相同的代码在jsfiddle但不会在我的服务器上运行?

本文发布于:2023-10-29 10:42:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539472.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   但不   器上   代码   jsfiddle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!