gpt4 book ai didi

javascript - jquery 和 javascript 冲突

转载 作者:行者123 更新时间:2023-11-28 10:59:46 25 4
gpt4 key购买 nike

我在母版页中使用 jquery,在内容页中使用 javascript。单独使用 Jquery 时效果很好。但是当我使用 javascript(内容页)和 jquery(母版页)时,母版页中的 jquery 停止工作。

母版页脚本

$(document).ready(function() {

// set up the accordion
$("#accordion>h3").click(function() {
$(this).next("div").slideToggle(500).siblings("div").slideUp(500);
});

// show active menu section
setTimeout('$("#accordion>div.activesec").slideToggle(800)', 100);

});

内容页面脚本

$('slideshow').style.display = 'none';
$('wrapper').style.display = 'block';
var slideshow = new TINY.slideshow("slideshow");
window.onload = function () {
slideshow.auto = true;
slideshow.speed = 5;
slideshow.link = "linkhover";
slideshow.info = "information";
slideshow.thumbs = "slider";
slideshow.left = "slideleft";
slideshow.right = "slideright";
slideshow.scrollSpeed = 4;
slideshow.spacing = 5;
slideshow.active = "#fff";
slideshow.init("slideshow", "image", "imgprev", "imgnext", "imglink");
}

最佳答案

我相信冲突是由于您在内容页面中使用 $ 简写引起的。 $ 用于表示 jQuery。因此,jQuery 试图解释 $('slideshow').style.display ,这不是有效的 jQuery。

将速记替换为 document.getElementById,或使用 jQuery 选择器。

标准 JS

document.getElementById.style.display = 'none';

或 jQuery

$('slideshow').css('display', 'none');

关于javascript - jquery 和 javascript 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6931559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com