发布于 2016-12-04 00:26:01 | 336 次阅读 | 评论: 0 | 来源: 网友投递
jQuery javascript框架
jQuery是一个兼容多浏览器的javascript框架,核心理念是write less,do more(写得更少,做得更多)。jQuery在2006年1月由美国人John Resig在纽约的barcamp发布,吸引了来自世界各地的众多JavaScript高手加入,由Dave Methvin率领团队进行开发。
<div class="messagewrap">
<ul>
<li><!--多个li,请自行复制或者设置重复区域--></li>
</ul>
<div class="bottomcover">
<!--为了符合w3c要求不能有空标签的要求,此处可选择写一个 -->
</div>
</div>
.messagewrap{overflow:hidden;position:relative;width:500px;height:300px}
li{height:50px;}
.bottomcover{width:500px;height:45px;position:absolute;bottom:0;left:0;
pointer-events:none;background:url(halftransp.png) left bottom no-repeat;
/*某从背景色向上渐变透明图片*/ _display:none;/*针对IE6体验降级*/}
<script>
$(function(){
msgmove();
$("ul").hover(function(){
$(this).attr("name","hovered"); //鼠标经过设置ul的name值为"hovered"
},function(){
$(this).removeAttr("name");
});
});
function msgmove(){
var isIE=!!window.ActiveXObject;
var isIE6=isIE&&!window.XMLHttpRequest;
if($("ul").attr("name") != "hovered"){
//判断ul的name属性是否为"hovered",决定下面代码块是否运行,以实现鼠标经过暂停滚动。
var height = $("li:last").height();
if(isIE6){
//判断IE6,jQuery的animate动画和opacity透明在一起使用在IE6中会出现中文重影现象,
//所以在ie6中实行透明的禁用。
$("li:last").css({"height":0});
}else{
$("li:last").css({"opacity":0,"height":0});
//列表最后的li透明和高度设置为0
}
$("li:first").before($("li:last"));
//把列表最后的li提升到顶部,实现有限列表项无限循环滚动显示
$("li:first").animate({"height":height},300);
//列表顶部的li高度逐渐变高以把下面的li推下去
if(!isIE6){
$("li:first").animate({"opacity":"1"},300);
//在非IE6浏览器中设置透明淡入效果
}
}
setTimeout("msgmove()",5000);
//设置5秒滚动一次
}
</script>