jQuery 无法正确渲染 [英] jQuery not rendering properly

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

问题描述

我正在使用这个 jQuery 来呈现一个文本框 onClick.但是,它不是渲染......另外,我使用的是 Drupal 7.我在 html.php 的 Head 标签中有 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.

See http://drupal.org/node/171213 for more details.

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

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