Implementation Code of jquery single-line text Scrolling up, jquery rolling code
<Body> <div id = "title" style = "width: 100%; height: 40px; "> look at the intermittent scrolling text </div> <div id =" content "class =" infocontent "> <div id =" top "class =" infolist "> <ul> <li> CCTV 315 exposure: china Resources is deeply immersed in the "Sea sand door", and the response is clear but not clear </li> <li> yoy's home was revealed that tableware is not disinfected, bosideng and other cashmere sweaters do not include cashmere </li> <li> Wuxi Police announced the "waiting for production "an unfortunate incident happened to female policemen. </li> <li> one day for Chinese: the final ferry View: "Done" at home </li> </ul> </div> <div id = "bottom" class = "infolist"> </div> <div id = "foot"> </div> </body>
.infolist{width:400px;matgin:0;} .infolist ul{margin:0;padding:0;} .infolist ul li{list-style:none;height:26px;line-height:26px;} .infocontent{width:400px;height:26px;overflow:hidden;border:1px solid #666666;}
Var interval = 1000; // interval between two scrolling times var stepsize = 26; // the length of one scrolling time, which must be a multiple of the row height, in this way, the line var objInterval = null; $ (document) will not be broken during scrolling ). ready (function () {// fill the lower part with the upper content $ ("# bottom" ).html ($ ("# top" ).html ()); // bind a mouse event to the displayed area $ ("# content "). bind ("mouseover", function () {StopScroll () ;}); $ ("# content "). bind ("mouseout", function () {StartScroll () ;}); // start the timer and start the rolling function StartScroll () {objInterval = setInterval ("verticalloop ()", interval);} // clear the timer and stop the rolling function StopScroll () {window. clearInterval (objInterval);} // controls the scroll function verticalloop () {// determines whether the upper part of the content is removed from the display area. // If yes, it starts from the beginning. Otherwise, move if ($ ("# content") up "). scrollTop () >=$ ("# top "). outerHeight () {$ ("# content "). scrollTop ($ ("# content "). scrollTop ()-$ ("# top "). outerHeight ();} // use jquery to create the animation effect when scrolling $ ("# content "). animate ({"scrollTop": $ ("# content "). scrollTop () + stepsize + "px"}, 600, function () {// This is used to display the scrollTop of the scrolling area, delete // $ ("# foot" ).html ("scrollTop:" + $ ("# content") in actual applications "). scrollTop ());});}
JS Code for single-row and upward scrolling text (for announcement)
----- Method 1: run the horse lamp <marquee> </marquee>. However, there will be an interval and it does not look beautiful.
----- Method 2
Three layers are required
----- Function is called during onload (Timer control is used)
<Script language = "javascript">
Function inti ()
{
Document. getElementById ("2"). innerHTML = document. getElementById ("1"). innerHTML;
Scroll1 ();
}
Function scroll1 ()
{
Var a = document. getElementById ("1 ");
Var B = document. getElementById ("2 ");
Var l = document. getElementById ("Layer1 ");
If (B. offsetTop = l. scrollTop)
{
L. scrollTop = 0;
}
Else
{
L. scrollTop ++;
}
SetTimeout ("scroll1 ()", 10 );
}
Function aaaa (){
Document. getElementById ("text1"). value =;
}
</Script>
-------- The following is the layer code, which is just an example. You only need to replace your own content
(Note: the text should not be too small; otherwise, the layer will not be able to understand the effect)
<Body onLoad = "inti ()">
<Div id = "Layer1" style ="
Overflow: hidden;
Width: 276px;
Height: 196px;
Z-index: 1; ">
<Div id = "1"> 1 <br/>
2 <br/>
3 <br/>
4 <br/>
5 <br/>
6 <br/>
7 <br/>
8 <br/>
9 <br/>
10 <br/>
11 <br/>
12 <br/>
13 <br/>
14 <br/>
15 <br/>
16 <br/>
17 <br/>
18 <br/>
19 <br/>
20 <br/>
21 <br/>
</Div>
<Div id = "2"> </div>
</Div>... remaining full text>
Single-Line Text scroll up code incompatibility question 100 points Thank you
Ah !~ I found myself ....!~ O (distinct _ distinct) O ~
It is compatible with the code for Scrolling up a single line of text in multiple browsers:
[Style as follows]
* {Margin: 0; padding: 0 ;}
. Bady {margin: 0; padding: 0; font-size: 12px; font-family: Arial "Al ";}
Div, input, dl, dd, dt, ul, li, p, h1, h2, h3, h4, h5, h6, p, fieldset {margin: 0; padding: 0 ;}
Ul, li {list-style: none ;}
Img, input {border: none ;}
A {text-decoration: none ;}
<! -- The above is the unified code -->
. Maintopm {width: 485px; height: 22px; float: left; border: # D0D0D0 1px solid; padding-left: 4px; overflow: hidden; background: # FFF; padding-top: 7px ;}
. Maintopm a {display: block; width: 485px; height: 22px; color: #555656; line-height: 20px; font-size: 12px ;}
. Maintopm a: hover {color: # F00 ;}
# Div1 {height: 22px; overflow: hidden ;}
[DIV]
<! -- Start with a single rolling news -->
<Div class = "maintopm">
<Div id = "div1">
<A href = "javascript:"> single-line text scroll up effects compatible with multiple browsers </a>
<A href = "javascript:"> supports multiple browsers with special effects of text Scrolling up </a>
<A href = "javascript:"> compatible with various browsers for text Scrolling up </a>
<A href = "javascript:"> very good text Scrolling up the Code </a>
<A href = "javascript:"> single-line text scroll up effects compatible with multiple browsers </a>
<A href = "javascript:"> the special effect of single-line text Scrolling up is 2010-10-10 compatible. </a>
</Div>
</Div>
<Script>
Var box = document. getElementById ("div1"), can = true;
Box. innerHTML + = box. innerHTML;
Box. onmouseover = function () {can = false };
Box. onmouseout = function () {can = true };
New function (){
Var stop = box. scrollTop % 22 = 0 &&! Can;
If (! Stop) box. scrollTop = parseInt (box. scrollHeight & #47 ...... the remaining full text>