jQuery在Wordpress中不起作用 [英] jQuery not working within Wordpress
问题描述
我有一些jQuery脚本,可以在这里找到: http://jsfiddle.net/RUqNN/45/
I have this bit of jQuery script that can be found here: http://jsfiddle.net/RUqNN/45/
当我将此脚本合并到wordpress模板中时,我将无法工作.
When I incorporate this script into my wordpress template, I doesn't work.
我已经检查了jquery的源链接,重写了代码,没有任何效果.
I've check the jquery source link, rewritten the code, nothing works.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$(".move").toggle(
function() {
$("#teetimetag").animate({
right: "0px"
}, "normal");
},function() {
$("#teetimetag").animate({
right: "-200px"
}, "normal");
});
});
</script>
<div id="teetimetag">
<img class="move" src="http://test.tooheavytoskydive.com/wp-content/themes/newtheme/images/flag.png" style="float: left;" />
<div style="margin: 15px 0 0 50px;">
<a href="http://test.tooheavytoskydive.com/reservations/" style="color: #FFF; font-weight: bold; font-size: 17px;">Reserve your Tee-Time</a>
</div>
</div>
</body>
</html>
推荐答案
您的网站显示以下javascript错误:"$不是函数".看起来jQuery与其他一些库冲突.这可以通过调用jQuery.noConflict()并将所有$替换为'jQuery'来解决.该代码将如下所示:
Your website gives the following javascript error: '$ is not a function'. It looks like jQuery conflicts with some other library. This can be solved by calling jQuery.noConflict() and replacing all $ with 'jQuery'. The code will look as follows:
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery(".move").toggle(
function() {
jQuery("#teetimetag").animate({
right: "0px"
}, "normal");
},function() {
jQuery("#teetimetag").animate({
right: "-200px"
}, "normal");
});
});
这篇关于jQuery在Wordpress中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!