jquery實現(xiàn)文字單行橫移或翻轉(zhuǎn)(上下、左右跳轉(zhuǎn))
通過jquery的animate實現(xiàn)上下單行自動跳轉(zhuǎn)
<script type="text/javascript" src="__ROOT__/Style/H/js/jquery-1.7.2.min.js"></script>
<style>
.rool-div{
height:50px;
width:700px;
margin:0 auto;
position: relative;
overflow: hidden;
border:2px solid red;
}
.roll{
height:50px;
width:700px;
margin:0 auto;
}
.roll span{
display:block;
height:50px;
width:700px;
line-height:50px;
}
a {
text-decoration:none;
display:inline-block;
}
</style>
<div class="rool-div">
<div class="roll" id="roll">
<span><a href="#">1. Lorem Ipsum is simply dummy text of the printing and typesetting industry</a></span>
<span><a href="#">2. It is a long established fact that a reader will be distracted</a></span>
<span><a href="#">3. Many desktop publishing packages</a></span>
<span><a href="#">4. All the Lorem Ipsum generators on the Internet tend to repeat predefined</a></span>
<span><a href="#">5. The standard chunk of Lorem Ipsum used</a></span>
<span><a href="#">6. English versions from the 1914 translation by H. Rackham.</a></span>
<span><a href="#">7. Bu metin deneme amaçlıdır the standard chunk of Lorem Ipsum used</a></span>
</div>
</div>
<script>
(function($){
$.fn.extend({
Roll:function(){
return this.each(function(){
var n=0;
$('#roll span a').hover(function(){
$(this).css('color','red');
},function(){
$(this).css('color','green');
});
var timername=setInterval(function(){Play()},1000);
$("#roll").hover(
function()
{
clearInterval(timername);
},
function()
{
timername=setInterval(function(){Play()},1000);
});
function Play(){
if($("#roll>span").length>n)
n++;
else
n=1;
$("#roll").animate({'marginTop':-($("#roll span" ).height())*(n-1)});
}
});
}
})
})(jQuery);
</script>
二 通過scrollLeft函數(shù)實現(xiàn)自動左右移動(谷歌瀏覽器偶爾不能移動)
<style type="text/css">
#demo {overflow:hidden;width:740px; }
#indemo { float: left; width: 800%;}
#demo1 { float: left; }
#demo2 { float: left;margin-left:7px;}
</style>
<script src="bootstrap-3.3.5-dist/js/jquery-1.11.3.js"></script>
<div id="demo">
<div id="indemo">
<div id="demo1">
<a href="#"><img src="zhuanpan/images/pointer.png" alt="#" /></a>
<a href="#"><img src="zhuanpan/images/pointer.png" alt="#" /></a>
<a href="#"><img src="zhuanpan/images/pointer.png" alt="#" /></a>
<a href="#"><img src="zhuanpan/images/pointer.png" alt="#" /></a>
<a href="#"><img src="zhuanpan/images/pointer.png" alt="#" /></a>
<a href="#"><img src="zhuanpan/images/pointer.png" alt="#" /></a>
</div>
<div id="demo2"></div>
</div>
</div>
<script>
var speed=10;
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
$("#demo2").text($("#demo1").clone());
$("#demo2").clone();
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft<=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
</script>
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!
相關(guān)文章
jQuery動態(tài)設(shè)置form表單的enctype值(實現(xiàn)代碼)
本篇文章是對在jQuery中動態(tài)設(shè)置form表單的enctype值的實現(xiàn)代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07
jQuery復(fù)合事件結(jié)合toggle()方法的用法示例
這篇文章主要介紹了jQuery復(fù)合事件結(jié)合toggle()方法的用法,實例分析了toggle()方法的功能、定義以及與復(fù)合事件結(jié)合使用的操作技巧,需要的朋友可以參考下2017-06-06
jquery中ajax調(diào)用json數(shù)據(jù)的使用說明
jquery里提供了便捷的ajax運用,下面總結(jié)我自己的一些經(jīng)驗2011-03-03
jQuery刪除節(jié)點的三個方法即remove()detach()和empty()
jQuery提供了三種刪除節(jié)點的方法,即remove(),detach()和empty(),下面為大家詳細(xì)介紹下jQuery刪除節(jié)點三個方法的具體使用2013-12-12
jquery tools系列 overlay 學(xué)習(xí)
接著上次scrollable的學(xué)習(xí),今天繼續(xù)jquery tools六大功能的第四個功能——overlay的學(xué)習(xí)。2009-09-09

