Home > JavaScript, jQuery > Linear scrolling text with jQuery

Linear scrolling text with jQuery

jQuery scrolling text like marquee

You don’t need to use an obsolete “marquee” tag to get a scrolling text effect; You can clean your HTML and use a cross-browser solution, try the following jQuery code that I wrote…
 

 

to create advanced horizontal/vertical scrolling text
take a look at jQuery Scroller Plugin at
http://maxvergelli.wordpress.com/jquery-scroller-plugin-scrolling-made-easy/

Happy scrolling!
Max :)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Simple jQuery scrolling function by Max Vergelli</title>
<style type="text/css">
	div.scroller{
		position:relative;
		height:24px;
		width:200px;
		display:block;
		overflow:hidden;
		border:#CCCCCC 1px solid;
	}
	div.scrollingtext{
		position:absolute;
		white-space:nowrap;
		font-family:'Trebuchet MS',Arial;
		font-size:18px;
		font-weight:bold;
		color:#000000;
	}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {

	$('.scrollingtext').bind('marquee', function() {
		var ob = $(this);
		var tw = ob.width();
		var ww = ob.parent().width();
		ob.css({ left: -tw });
		ob.animate({ left: ww }, 20000, 'linear', function() {
			ob.trigger('marquee');
		});
	}).trigger('marquee');

});
</script>
</head>
<body>

<div class="scroller">
	<div class="scrollingtext">
		scrolling text scrolling text scrolling text scrolling text scrolling text
	</div>
</div>

</body>
</html>

Advertisement
  1. Chafik
    12 April 2010 at 20:57 | #1

    Thanks for code
    Very usefull
    unforunnately, I dont now how to make it stop on mouse hover

  2. 20 September 2010 at 00:49 | #3

    perfecto!

  3. Rob
    27 October 2010 at 18:11 | #4

    Thanks…This is cool… how do I get it to 1. scroll a list inline and 2. so it looks like a continuous loop?

  4. 15 March 2011 at 14:15 | #5

    Hello,
    Nice script. It’s working fine.
    Just one question: is it possible to have the scrolling text begin immediately after the end of the last word, as if there was no end ?

    Thanks!

  5. 30 March 2011 at 00:38 | #6

    Can this be used to scroll and array of users?

    Example: Picture of user 1, name of user 1, last post of user 1, Picture of user 2, ect..

  6. 6 April 2011 at 07:53 | #7

    For problems with larger text (jumps to start), just change

    ob.animate({ left: ww }, 20000, ‘linear’, function() {

    to for example

    ob.animate({ left: -(3 * ww) }, 80000, ‘linear’, function() {

    hope it helps someone

  7. 22 July 2011 at 18:17 | #8

    niceeeee :D
    i’ll try….best alternate method of outdated marquee :D
    thnx

  8. 13 August 2011 at 03:53 | #9

    How to change the background color of text marquee..its transparent and I want my fonts RED and background Black…

  9. 13 August 2011 at 03:59 | #10

    Also how to add mouseover and mouseout as you mentioned, please do let me know I am not an expert in Html…

  10. Sisir Dsa
    29 November 2011 at 08:08 | #11

    Hi

    how to change to alternate marque style like it should go left to right and right to left

    Thanks,
    Sisir

  11. Anand
    28 December 2011 at 05:28 | #12

    How to make marquee stop on mouse-over?

  12. Russell Clark
    6 February 2012 at 18:20 | #13

    The jquery site is still down & I would like to try out scroller

  13. 16 February 2012 at 11:46 | #14

    thx bro,
    very usefull coding :D

  14. Emmanuel
    17 February 2012 at 10:24 | #15

    Hi, it took me more time to write this message than to install and make it work on my site! Thanks a lot

  15. wo
    22 February 2012 at 21:24 | #16

    Michael :
    Hello,
    Nice script. It’s working fine.
    Just one question: is it possible to have the scrolling text begin immediately after the end of the last word, as if there was no end ?
    Thanks!

    This is good question

  1. 17 September 2010 at 02:18 | #1
  2. 4 January 2011 at 17:06 | #2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 32 other followers