jQuery没有正确呈现 [英] jQuery not rendering properly

查看:240
本文介绍了jQuery没有正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个jQuery来渲染一个文本框onClick。但是,它不是渲染...另外,在旁注我使用Drupal 7.我有html.php的头标签中的jQuery。

I'm using this jQuery to render a text box onClick. But, It's not rendering... Also, on a side note I'm using Drupal 7. I have the jQuery in the Head tags of the html.php.

 <script type="text/javascript">

  $(document).ready(function() {

    $("#front-background").hide();

        $(window).load(function() {

            $('#links-top-1').hover(function() {

                $('#front-background').fadeIn(2000);

            });

        });

  });

  </script>


推荐答案

这也可能是因为Drupal如何处理与其他JavaScript库。

This may also be because of how Drupal handles compatibility with other JavaScript libraries.

您可以将jQuery函数包装到:

You can wrap your jQuery function in:

(function ($) {
    //your existing code
})(jQuery);

或者如果您使用 template.php 文件,您可以通过函数 drupal_add_js()添加JS。

or if you're comfortable theming using the template.php file, you can add the JS through the function drupal_add_js().

请参阅 http://drupal.org/node/171213 更多细节。

这篇关于jQuery没有正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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