您的位置:首页 > 编程语言

jQurey的一点自己代码

2016-02-17 00:00 330 查看
1、关于children

$(function(){
varconbg=["images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg","images/about/IMG_03.jpg"];
var tabl=jQuery(".content_r_yuan dl").children().length;
var showtab=function(tab){
for(i=0;i<tab1;i++){
jQuery(".content_r_yuan dl").eq(i).hide();
jQuery(".content_r_bj ul").eq(i).hide();
jQuery(".p_desc").eq(i).hide();
}
jQuery(".content_r_yuan dl").eq(tab).show();
jQuery(".content_r_bj ul").eq(tab).show();
jQuery(".p_desc").eq(tab).show();
}
jQuery("#tabstabs dd").click(function(){
varindex=$(this).index();showtab(index);
})
$(".content_r_yuan dl").eq(0).children().mouseover(
function(){
var index=$(this).index();
$(this).children("a").addClass("hover1");
$(this).siblings().children("a").removeClass("hover1");
$(".p_desc").eq(0).children("p").eq(index).show().siblings().hide();
$(".content_r_banner").css({"background":"url("+conbg[index]+")"});
}
);
$(".content_r_bjul").eq(0).children("li").mouseover(
function(){
var index=$(this).index();
$(".p_desc").eq(0).children("p").eq(index).show().siblings().hide();
$(".content_r_banner").css({"background":"url("+conbg[index]+")"});
}
);
$(".content_r_yuan dl").eq(1).children().mouseover(
function(){
var index=$(this).index();
$(this).children("a").addClass("hover1");
$(this).siblings().children("a").removeClass("hover1");
$(".p_desc").eq(1).children("p").eq(index).show().siblings().hide();
$(".content_r_banner").css({"background":"url("+conbg[index]+")"});
}
);
$(".content_r_bjul").eq(1).children("li").mouseover(
function(){
var index=$(this).index();
$(".p_desc").eq(1).children("p").eq(index).show().siblings().hide();
$(".content_r_banner").css({"background":"url("+conbg[index]+")"});
}
);
$(".content_r_yuan dl").eq(2).children().mouseover(
function(){
var index=$(this).index();
$(this).children("a").addClass("hover1");
$(this).siblings().children("a").removeClass("hover1");
$(".p_desc").eq(2).children("p").eq(index).show().siblings().hide();
$(".content_r_banner").css({"background":"url("+conbg[index]+")"});
}
);
$(".content_r_bjul").eq(2).children("li").mouseover(
function(){
var index=$(this).index();
$(".p_desc").eq(2).children("p").eq(index).show().siblings().hide();
$(".content_r_banner").css({"background":"url("+conbg[index]+")"});
});
});


2、关于背景焦点图,一个老外需要兼容所有浏览器宽度,因此只能使用背景焦点图,其实背景焦点图也是可以向左移动切换的。带会儿再发

3、FLV视频播放,我用的笑傲江湖的FLV播放器

$(function(){

ajax("{'act':'is_rensheng'}");

if (amsg != ''){
$('#exam_video_r').html(amsg);
}
var fvideo = $("#fvideo").attr("value");
addVideoPlayer('video-area', 480, 360, { playlist: fvideo, autoPlay: 'true', repeatMode: 0 });
$(".exam_video_r_v li").click(function(){
var videolink=$(this).children("img").attr("rel");
var index=$(this).index();
$(".exam_video_r_t").html($(this).children("p").html());
$(".exam_video_r_n dl").eq(index).show().siblings().hide();
addVideoPlayer('video-area', 480, 360, { playlist: videolink, autoPlay: 'true', repeatMode: 0 });
})
});


4、腾讯弹窗,将腾讯弹窗改成了Jquery版本,简单,很简单的自定义样式,不用再用复杂的什么artdialog等等。


CSS样式


.layoutBg{width:100%;height:4250px;position:absolute;top:0;left:0;z-index:8888;display:none;background:url(http://mat1.gtimg.com/www/images/qq2012/alphabg.png);}


<script type="text/javascript">$(function(){
$(".pro_text li").click(function(){
var src=$(this).children("img").attr("rel");
$("#layoutBg").show();
$("#layoutBg").height(document.body.clientHeight);
$("#login_frame").attr("src",src);
$("#login_div").css({"left":"50%"});
$("#login_div").show();
});
});</script>


<div id="layoutBg" class="layoutBg"></div>
<div id="login_div" style="position:fixed;_position:absolute;width:865px;height:555px;padding:0;margin:0;top:50%;left:-9999px;margin:-268px 0 0 -420px;z-index:9999;">
<iframe id="login_frame" height="100%" scrolling="auto" width="100%" frameborder="0" src=""></iframe>
</div>


子页面应该有个关闭按钮,如何访问父窗体元素呢?,下面是核心代码,兼容所有浏览器咯


$("#diaclose").click(function(){

$("#login_div",window.parent.document).css({"left":"-9999px"});

$("#layoutBg",window.parent.document).hide();

});

太囧笑话网
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: