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 无法正确渲染
基础教程推荐
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
