使用下拉菜单排除jquery错误

Troubleshoot jquery error with dropdown menu

本文关键字:jquery 错误 排除 下拉菜单      更新时间:2023-09-26

存在某种jquery冲突,我无法理解。我有一个脚本在这里自己工作:

http://www.pitestiretailpark.ro/working.html

当将相同的脚本插入Joomla页面(以及html/css代码)时,下拉菜单将不起作用。

http://www.pitestiretailpark.ro/test/

我不是程序员,我知道我的HTML,但对jquery知之甚少。独立脚本已经从另一个页面复制,被剥离(但有效!),当我试图插入Joomla时,它停止了工作。

还有另一个lib使用$符号作为函数。使用这样的jQuery.noConflict()方法;

jQuery.noConflict();
jQuery( document ).ready(function( $ ) {
  // your code
});

用jQuery替换脚本中的$,也可以在文档就绪时调用它:

jQuery(document).ready(function() {
    jQuery('.div_btn_menu').hover(
        function() {
            jQuery(this).children('.div_sous-menu').css('top',$(this).children('.btn_menu').height()+'px')
            jQuery(this).css('z-index',10000000)
            jQuery(this).children('.div_sous-menu').stop(true,true).fadeIn(200)
        },
        function() {
            jQuery(this).css('z-index',1)
            jQuery(this).children('.div_sous-menu').stop(true,true).fadeOut(200)
        }
    );
})