jQuery not rendering properly(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 无法正确渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery 无法正确渲染


- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01