jQuery在任何浏览器中都不起作用(没有任何效果),但它在Codepen中工作
jQuery not working (not having any effect) in any browser, but it works in Codepen
这让我感到沮丧已经很久了。我尝试将jQuery下载为本地文件,并尝试将其链接到http。路径是正确的,实际代码中没有错误,因为它在 Codepen 中完美运行。它位于正确的位置。我尝试将其放在<head>
标签中,也放在</body>
标签之前,但仍然没有运气 - 没有任何反应。在这里:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="/js/javascript.js"></script>
我尝试使用的代码是:
$(document).ready(function() {
$('.item').hover(function() {
$(this).stop().animate({ width: '100%' }, 500);
}, function() {
$(this).stop().animate({ width: '96%' }, 500);
});
});
有什么理由可以这样吗?常规的Javascript工作正常,当我尝试做一个简单的警报('hello');它也可以工作。这真的很令人沮丧,欢迎任何建议!
这是代码笔的链接:http://codepen.io/Pea92/pen/WvrXRY
这段代码对我有用,你应该尝试删除外部.js()
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
$(document).ready(function(){
$("button").click(function(){
var div = $("div");
div.animate({left: '100px'}, "slow");
div.animate({fontSize: '3em'}, "slow");
});
});
</script>
</head>
<body>
<br />
<button>Click Here</button>
<p>This is a example of jquery 2.1.1 to show and hide contain on view page </p>
<p> below example for animation effect on dataweb view page with jquery 2.1.1 </p>
<div style="background:#98bf21;height:100px;width:200px;position:absolute;">Example</div>
</body>
相关文章:
- 函数参数中的数据与指定变量之间的任何性能差异
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- jQuery中是否内置了任何字符串格式化函数
- 在单击任何位置时隐藏元素,而不检查每次DOM单击
- 是否有任何snippet或jQuery插件可以列出easylist.txt模式匹配的DOM中的所有元素
- 有任何可能将facebook实时信使整合到一个网站中
- 是否有任何方法可以使用jQuery替换在数组中定义值的文本
- AJAX:$_GET不返回任何值
- 在同一个服务工作者中处理service-worker.js有任何影响吗
- 将事件处理程序绑定到任何可能的事件
- 在Highcharts中,我们可以通过任何方式在渲染图表之前获得plotWidth和plotHeight
- 任何方式使AJAX调用Gmail API,而无需通过JS库
- document.styleSheets不返回任何内容
- 在D3.js中,有没有任何方法可以将x和y方向上的滚动事件绑定到平移svg
- Graphiti中是否有任何工具提示功能
- 有没有任何方法可以使用node-js从不同的机器打开浏览器
- 在解析对象.save()中;没有返回任何原因
- 任何浏览器都不支持javascript函数
- gmap3如何做到这一点-它显示圆圈的任何事件
- jQuery在任何浏览器中都不起作用(没有任何效果),但它在Codepen中工作