Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery代码在测试中工作,但不在现场_Javascript_Jquery_Html_Wordpress - Fatal编程技术网

Javascript jQuery代码在测试中工作,但不在现场

Javascript jQuery代码在测试中工作,但不在现场,javascript,jquery,html,wordpress,Javascript,Jquery,Html,Wordpress,所以我有下面的代码 <script src="http://jamesleist.com/wp-content/uploads/2013/01/js/jquery-1.7.2.min.js" type="text/javascript"></script> <script> $(document).ready(function() { $('.me').hide(); $('.clickme').click(functi

所以我有下面的代码

<script src="http://jamesleist.com/wp-content/uploads/2013/01/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function() {
        $('.me').hide();
        $('.clickme').click(function() {
            $(this).next('.me').animate({
                height: 'toggle'
            }, 500);
        });
    });
</script>    

<div class="clickme" style="background-color: #333333; color: #FFFFFF; padding: 10px; width: 200px; cursor:pointer;">
  Click here to toggle me in and out =)
</div>
<img class="me" src="http://www.randomsnippets.com/wp-content/uploads/2011/04/2.png" alt="It&#039;s me....ah!!!" title="Allen Liu" width="100" height="77" class="alignnone size-full wp-image-552" style="border: none;" />

<div class="clickme" style="background-color: #333333; color: #FFFFFF; padding: 10px; width: 200px; cursor:pointer;">
  Click here to toggle me in and out =)
</div>
<img class="me" src="http://www.randomsnippets.com/wp-content/uploads/2011/04/2.png" alt="It&#039;s me....ah!!!" title="Allen Liu" width="100" height="77" class="alignnone size-full wp-image-552" style="border: none;" />

$(文档).ready(函数(){
$('.me').hide();
$('.clickme')。单击(函数(){
$(this).next('.me').animate({
高度:“切换”
}, 500);
});
});
单击此处切换我的输入和输出=)
单击此处切换我的输入和输出=)
当它自己运行时,它工作得很好,但是当我在主站点中实现它时,它就不工作了

您可以在下面的URL中看到我尝试实现它的地方

这让我很困惑:-(顺便说一下,我正在使用Wordpress,jQuery在header.php文件中链接到

我想这是Wordpress的问题吧


非常感谢您的帮助。

您的
img
标签定义了两个
class
属性。我不确定这是否是100%的原因,但这肯定应该得到修复

像这样:

<img class="me alignnone size-full wp-image-552" src="http://www.randomsnippets.com/wp-content/uploads/2011/04/2.png" alt="It&#039;s me....ah!!!" title="Allen Liu" width="100" height="77" style="border: none;" />

.me
不是下一个元素,下一个元素是包含图像的段落吗

$(document).ready(function() {
    $('.me').hide();
    $('.clickme').on('click', function() {
        $(this).next('p').find('.me').animate({
            height: 'toggle'
        }, 500);
    });
});

您的图像定义了两次“类”,您不能这样做。您需要将所有类(包括“me”类)包含在一个用空格分隔的类声明中。通过一个简单的实例可以清楚地显示错误


我也会考虑把你的脚本内部和外部移动到你的页面底部,这样DOM就不会等待它们加载。把你所有的内嵌样式移到样式表也是个好主意,所以你的代码更容易阅读和调试。< /P> @ AdPrPracer--不,但是在不工作的网站上,问题是PA。图片周围的碎布!感谢您的帮助:-)