JQuery 新闻头条淡入淡出效果

新闻头条淡入淡出效果

sss

<!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=UTF-8">
<title></title>
<style>
a { color:#CCCCCC}
li { list-style:none;}
span { padding-right:20px; color:#FFFFFF; font-weight:bold;}
</style>
</head>
<body>
 <div id="ticker" style="padding:10px; background:#333333">
        <!-- START TICKER VER 1.0.1 -->
 <script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
/* =========================================================
// jquery.innerfade.js
// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com
// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/
 *
 *  <ul id="news">
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *
 *  $('#news').innerfade({
 *	  animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'),
 *	  speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'),
 *	  timeout: Time between the fades in milliseconds (Default: '2000'),
 *	  type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'),
 * 		containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *	  runningclass: CSS-Class which the container get’s applied (Default: 'innerfade'),
 *	  children: optional children selector (Default: null)
 *  });
 *
// ========================================================= */
(function($) {
    $.fn.innerfade = function(options) {
        return this.each(function() {
            $.innerfade(this, options);
        });
    };
    $.innerfade = function(container, options) {
        var settings = {
        		'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
            		var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do {
												current = Math.floor ( Math.random ( ) * ( elements.length ) );
										} while (last == current );
										$.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
    };
    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };
})(jQuery);
// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}
</script>
<script type="text/javascript">
  jQuery.noConflict();
  // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
	jQuery('#news').innerfade({
						 speed: '1',
						 timeout: 2000,
						 containerheight: 20,
						 animationtype: 'fade'
	  });
	});
  </script>
        <ul id="news" style="overflow: hidden; display:block; margin:0; clear:both">
          <li style="z-index: 5; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Racing has begun at the 2009 AllegroCup Windsurfing Championship in ?eba, Poland. This event, organised by... </a></li>
          <li style="z-index: 4; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Sean is currently racing at the Euro-Challenger FW Event in Pobierowo, Poland. A small seaside town on the... </a></li>
          <li style="z-index: 3; position: absolute; display: list-item;"><span>HOT NEWS</span><a href="#">Sean will be joining the dark side of windsurfing this season, on the International Team for Point-7 sails.... </a></li>
          <li style="z-index: 2; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Sean's all new website for 2009 launched today! Stay tuned for features on many CSS galleries once more. The... </a></li>
          <li style="z-index: 1; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Sean has just arrived in Europe and settled in to his training-base in the Netherlands, preparing for this... </a></li>
        </ul>
        <!-- END TICKER -->
      </div>
</body>
</html>

212 thoughts on “JQuery 新闻头条淡入淡出效果

  1. tomford sunglasses

    I want to show some thanks to the writer just for bailing me out of such a predicament. Right after looking through the internet and seeing tricks which are not productive, I believed my entire life was done. Being alive minus the strategies to the problems you have fixed by means of your good review is a crucial case, as well as ones that could have in a wrong way damaged my career if I had not encountered your web site. Your actual capability and kindness in playing with everything was invaluable. I am not sure what I would have done if I had not come upon such a stuff like this. I can also at this time look forward to my future. Thanks a lot so much for the expert and result oriented help. I won’t think twice to propose your web page to anybody who will need care about this situation.

  2. nike air max 90

    Thank you a lot for giving everyone remarkably memorable opportunity to discover important secrets from this blog. It’s usually so nice and also packed with amusement for me personally and my office mates to visit the blog minimum 3 times per week to see the fresh items you have. And definitely, we’re certainly pleased with the gorgeous thoughts you give. Some 2 facts in this article are in truth the very best we have ever had.

  3. fila shoes

    My spouse and i got excited Chris managed to do his preliminary research via the precious recommendations he had using your web site. It is now and again perplexing just to find yourself freely giving methods which most people might have been trying to sell. And we take into account we have the writer to thank because of that. The main illustrations you made, the straightforward site navigation, the relationships you will help foster – it’s all wonderful, and it is helping our son in addition to us recognize that that topic is enjoyable, which is certainly wonderfully essential. Many thanks for everything!

  4. prada glasses

    I not to mention my pals were studying the great techniques on the website and quickly I got a horrible feeling I never thanked you for those tips. The guys had been so thrilled to study them and have in effect unquestionably been having fun with them. Appreciation for actually being indeed helpful and then for deciding upon certain fantastic areas millions of individuals are really desperate to understand about. Our own sincere regret for not expressing appreciation to earlier.

  5. kate spade handbags

    I simply wanted to write down a simple comment so as to say thanks to you for all the nice tricks you are giving out at this website. My time intensive internet search has at the end been recognized with incredibly good insight to write about with my visitors. I would say that most of us site visitors are extremely lucky to live in a great website with very many special people with very helpful tactics. I feel extremely happy to have used your entire weblog and look forward to some more fabulous moments reading here. Thanks a lot once more for everything.

  6. moncler outlet

    I’m just writing to make you understand of the fine discovery my wife’s princess undergone studying your site. She noticed so many details, including how it is like to possess an awesome giving character to let other individuals very easily completely grasp specific problematic subject areas. You really surpassed her expectations. Thank you for distributing the invaluable, trustworthy, revealing and in addition easy thoughts on your topic to Mary.

  7. pandora charms

    My husband and i were so glad Chris managed to deal with his researching by way of the precious recommendations he came across while using the blog. It is now and again perplexing to simply possibly be giving away facts which often men and women might have been selling. We really grasp we’ve got you to be grateful to for this. The entire illustrations you made, the easy site navigation, the relationships you make it easier to engender – it’s got most astounding, and it is leading our son in addition to us reason why this matter is cool, which is certainly quite serious. Thank you for the whole lot!

  8. kobe basketball shoes

    Thank you a lot for giving everyone an extraordinarily pleasant chance to discover important secrets from this site. It can be very fantastic and also jam-packed with a good time for me personally and my office acquaintances to search your blog no less than thrice per week to see the new tips you have got. Not to mention, I’m at all times pleased considering the staggering information you serve. Certain 4 areas on this page are in reality the simplest we have had.

  9. yeezy

    I definitely wanted to develop a simple comment so as to thank you for these stunning tips and tricks you are giving out at this website. My time intensive internet research has at the end been recognized with excellent ideas to exchange with my good friends. I would mention that we visitors are unequivocally blessed to exist in a perfect place with many perfect individuals with valuable opinions. I feel quite privileged to have come across your web page and look forward to really more entertaining minutes reading here. Thank you once more for a lot of things.

  10. yeezy boost

    My wife and i were absolutely satisfied Edward could finish off his research through your precious recommendations he had from your very own web page. It is now and again perplexing to simply choose to be giving out strategies that a number of people have been trying to sell. Therefore we remember we have got you to thank because of that. Most of the illustrations you’ve made, the easy web site navigation, the relationships you can make it possible to instill – it’s everything terrific, and it is leading our son and our family understand that concept is excellent, which is wonderfully important. Thank you for everything!

  11. nike react flyknit

    Thanks a lot for giving everyone remarkably special possiblity to read critical reviews from this site. It is often very excellent plus stuffed with fun for me personally and my office co-workers to visit the blog at the least thrice in one week to read through the latest guides you will have. And indeed, I’m just always astounded concerning the magnificent secrets served by you. Selected 1 tips in this article are in reality the most impressive we have all had.

Comments are closed.