我还是 jquery 的新手,在这里需要一些帮助:-) 当我在 Chrome 中离线时,此代码有效,一旦我尝试在 IE9 或 Firefox 中使用它,它就无法工作。所以我上传该网站,现在它甚至无法在 Chrome 中运行。
我在 Firefox 和 IE 中收到一条错误消息,告诉我“事件未定义”第 8 行 --> event.preventDefault();
它可以是什么?错误的链接? 在 html 中,它们是这样添加的:
问题解决了 这条线解决了问题:
$('.hidden_nav ul li a').click(function(event){
event.preventDefault();
这是函数(事件)。我留下了一个空函数()
感谢大家
$(document).ready(function(){
//Get size of docuement and apply to div grid
var height = $(document).height();
$('.theGrid').css('height',height);
// Slide Down hidden Content
$('.hidden_nav li a').click(function(){
event.preventDefault();
var selected = $(this).text().toLowerCase();
var thisone = $('#'+ selected);
$('.hidden_content').slideDown(200);
thisone.slideDown(200);
thisone.addClass('online')
$('.bubble').fadeIn(100).delay(2000).hide(300);
});
$('.close_btn').click(function(){
$('.hidden_content').slideUp(200);
$('.online').hide().removeClass('.online');
$('.bubble').hide();
});
//Design Process // a few $ animations
$('.step_img').mouseover(function(){
var sel = $(this).next('h4').text().toLowerCase();
thisone = $('#' + sel);
thisone.children('p').slideDown(100);
});
$('.step_img').mouseout(function(){
var sel = $(this).next('h4').text().toLowerCase();
thisone = $('#' + sel);
thisone.children('p').delay(1000).slideUp(400);
});
// Slider (Nivo Slider Plugin) effects
$('.slider').nivoSlider({
effect:'random',
startSlide:2,
directionNav: true,
pauseOnHover: true,
pauseTime: 6000,
});
});
最佳答案
仔细检查您的文件是否正确加载了 jquery 库。如果您在本地使用相对路径,请确保它们在服务器上相同。
关于jquery 只能在 chrome 中离线使用,根本不能在线使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11024983/