Javascript jquery代码是否与其他代码中断?
我认为我的问题很小,但我仍然需要jquery代码的帮助,我认为这都是关于js语法的:Javascript jquery代码是否与其他代码中断?,javascript,jquery,syntax-error,Javascript,Jquery,Syntax Error,我认为我的问题很小,但我仍然需要jquery代码的帮助,我认为这都是关于js语法的: $(function() { // Options for SuperBGImage $.fn.superbgimage.options = { randomtransition: 2, // 0-none, 1-use random transition (0-7) z_index: -1, // z-index for the contain
$(function() {
// Options for SuperBGImage
$.fn.superbgimage.options = {
randomtransition: 2, // 0-none, 1-use random transition (0-7)
z_index: -1, // z-index for the container
slideshow: 1, // 0-none, 1-autostart slideshow
slide_interval: 2000, // interval for the slideshow
randomimage: 1, // 0-none, 1-random image
speed: 'slow' // animation speed
};
// initialize SuperBGImage
$('#thumbs').superbgimage().hide();
});
$(function() {
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j('.menu-nav li').hover(
function() {
$j(this).addClass("active");
$j(this).find('.ulwrapper').stop(false, true).fadeIn();
$j(this).find('.ulwrapper .ulwrapper').stop(false, true).fadeOut('fast');
},
function() {
$j(this).removeClass("active");
$j(this).find('div').stop(false, true).fadeOut('fast');
}
);
$j('.ulwrapper').hover(
function() {
$j('.parent').addClass("active_tab");
},
function() {
$j('.parent').removeClass("active_tab");
}
);
});
});
第一个代码用于大图像,另一个代码用于我的多级菜单。我试图通过改变来解决这个问题
$(function() {
到
但是浏览器只运行一个代码!给了我:
Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function
(anonymous function)
我正在等待您的帮助,非常感谢。一旦您调用jQuery.noConflict,“$”绑定将不再工作。您不会说为什么要调用它,但可以只使用“jQuery”而不是“$”。您的“$j”变量是调用“noConflict”的函数的局部变量 此外,这样做也没有意义:
$(function() {
$(function() {
// ...
});
});
这就是你在第二个“就绪”处理器中所做的。也就是说,您正在从另一个处理程序内部设置一个“就绪”处理程序,这实际上毫无意义。要在脚本中使用$j,您应该插入以下代码:
<script type="text/javascript">
$j=jQuery.noConflict();
</script>
$j=jQuery.noConflict();
祝你好运。你为什么打电话给“.noConflict()”?没错,谢谢你的帮助。这两个函数现在都运行得很好。我只是按照Pointy的建议删除了noConflict,但非常感谢您的参与。
<script type="text/javascript">
$j=jQuery.noConflict();
</script>