教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 jquery 模拟雅虎首页的点击对话框效果

jquery 模拟雅虎首页的点击对话框效果

发布时间:2013-08-20   编辑:jiaochengji.com
jquery模拟雅虎首页的点击对话框效果实现代码,喜欢的朋友可以参考下。
jquery模拟雅虎首页的点击对话框效果实现代码,喜欢的朋友可以参考下。 这里说明下,这样的效果脚本之家发过类似的效果。具体的可以到脚本下载中心查找。

效果图:

声明:我做的只是实现这个效果,在美观上并没有做到yahoo主页这么好看,所以不要介意!

原材料:

思路:

1:为每一个li标签添加悬浮事件

2:构建iframe并获取到当前li标签下的a元素的href属性值

3:构建DIV包含iframe元素并显示
HTML结构:

复制代码 代码如下:

<ul>
<Li><a href="http://www.google.cn">新闻</a></Li>
<li><a href="http://www.163.com">体育</a></li>
<li><a href="http://www.sina.com">娱乐</a></li>
</ul>

CSS样式:
复制代码 代码如下:

ul{
float:left;
}
ul li{
display:block;
margin-top:15px;
width:100px;
position:relative;
}
a{
text-decoration:none;
color:#8000ff;
}
.show{
width:640px;
height:506px;
position:absolute;
top:-45px;
left:30px;
background:url(1.gif) no-repeat;
padding:45px 20px 35px 40px;
}
.close{
width:22px;
height:22px;
float:right;
display:block;
margin-top:-30px;
background:url(2.gif) no-repeat;
}
.quick{
position:absolute;
top:0px;
left:30px;
background:url(3.jpg) no-repeat;
width:37px;
height:26px;
font-size:12px;
color:white;
line-height:26px;
text-align:center;
}

JS代码:
复制代码 代码如下:

$(document).ready(function(){
$('ul li a').hover(function(e){
var quickw=$(this).parent().parent().find('#clickdiv');
if(quickw){
$('#clickdiv').remove();
}
$(this).parent().append('<div id="clickdiv">预览</div>');
$('#clickdiv').addClass('quick');
$("#clickdiv").click(function(){
$(this).css('display','none');
var url=$(this).parent().find('a').attr('href');
var $basediv=$(this).parent().parent().find('#window');
if($basediv){
$('#window').remove();
$(this).parent()
.append("<div id='window'><div id='closebutton'><a href='#'></a></div><iframe frameborder='0' hspace='0' src='"+url+"' style='width:640px;height:506px;'></iframe></div>")
.fadeIn('slow');
$("ul li #window").addClass('show');
$('#closebutton a').addClass('close');
$('#closebutton a').click(function(){
$("ul li #window").remove();
});
}
});

您可能感兴趣的文章:
jquery 模拟雅虎首页的点击对话框效果
jquery 模式对话框终极版实现代码
【精品推荐】web开发人员应该知道的31个jQuery模态对话框
JQUERY dialog的用法详细解析
快速关键词排名百度首页的优化方法
虎牙直播进不去 虎牙直播有画面没有声音怎么办
jQuery UI组件 jQuery UI
jQuery弹出对话框 jmodal
虎牙直播常见问题汇总
jQuery模式对话框 nyroModal

[关闭]
~ ~