Javascript 在另一页上打开Jquery Div;“散列”;
我想使用链接在不同的页面上打开一个div 链接如下所示:grid.html#project1/2/3/4等 目标页面上的代码如下所示:Javascript 在另一页上打开Jquery Div;“散列”;,javascript,jquery,hash,Javascript,Jquery,Hash,我想使用链接在不同的页面上打开一个div 链接如下所示:grid.html#project1/2/3/4等 目标页面上的代码如下所示: $(function(){ // Thumbs $('#thumbs a').hover(function(){ $(this).find('span').stop(true, true).animate({'top': '90px'}, 300) }, function(){ $(this
$(function(){
// Thumbs
$('#thumbs a').hover(function(){
$(this).find('span').stop(true, true).animate({'top': '90px'}, 300)
}, function(){
$(this).find('img').stop(true, true).animate({}, 300);
$(this).find('span').stop(true, true).animate({'top': '124px'}, 300)
}) .bind('click', function(){
$('#content .project').stop(true, true).fadeOut(500);
$($(this).attr('href')).stop(true, true).css('left', 0).fadeIn(500);
$('#content').animate({'min-height' : '450px', 'display' : 'inline', 'position' : 'relative', 'paddingTop' : '-2px' , 'paddingBottom' : '130px'}, 500);
$('#thumbs').animate({'marginTop' : '30px'}, 500);
$('html,body').animate({scrollTop:0}, 500);
return false;
});
$(".close").click(function() {
$('#content .project').fadeOut(500);
$('#content').animate({'min-height' : '0px', 'display' : 'inline', 'position' : 'relative', 'paddingTop' : '0px' , 'paddingBottom' : '0px'}, 500);
});
// Carousel
$('.carousel').jcarousel({
scroll: 1,
animation: 800,
easing: 'easeOutQuart',
buttonNextHTML: '<div><div></div></div>',
buttonPrevHTML: '<div><div></div></div>',
initCallback: initCarousel
});
});
$(函数(){
//拇指
$('#拇指a')。悬停(函数(){
$(this.find('span').stop(true,true).animate({'top':'90px'},300)
},函数(){
$(this.find('img').stop(true,true).animate({},300);
$(this.find('span').stop(true,true).animate({'top':'124px'},300)
}).bind('单击',函数()){
$('#content.project').stop(true,true).fadeOut(500);
$($(this.attr('href')).stop(true,true).css('left',0).fadeIn(500);
$(#content')。动画({'min-height':'450px','display':'inline','position':'relative','paddingTop':'-2px','paddingBottom':'130px'},500);
$('拇指').animate({'marginTop':'30px'},500);
$('html,body').animate({scrollTop:0},500);
返回false;
});
$(“.close”)。单击(函数(){
$(#content.project')。淡出(500);
$(#content')。动画({'min-height':'0px','display':'inline','position':'relative','paddingTop':'0px','paddingBottom':'0px'},500);
});
//旋转木马
$('.carousel').jcarousel({
卷轴:1,
动画:800,
放松:“easeOutQuart”,
buttonNextHTML:“”,
按钮预览HTML:“”,
initCallback:initCarousel
});
});
谢谢!有点用。现在,当我单击页面上项目所在的对象时,链接会出现在地址栏中,这是以前没有的。但是,我不知道如何从另一个页面创建链接。我的动画也有点结巴/滞后,但这可能是我放错了代码。如果你只是链接到grid.html#project1,它肯定会工作吗?恐怕不行。我把代码放在:$('html,body').animate({scrollTop:0},500)后面;您用您的div替换了$('#content.project')的所有实例?是的,不幸的是它不起作用。我很难找到关于这个解决方案的网站。不管怎样,我很乐意提供一些关于这个主题的链接,看看我是否能学到/看到一些东西。
var hash = window.location.hash;
var yourDiv = $('#content .'+hash);