hyperlink - Timed jquery fadeout - creating links -
i found cool jquery fade in/fade out script, can't quite figure out how alter script make text href link (i want use news ticker). i've spent hours fiddling jquery isn't par. example i've tried put <a href="#">test line 1</a>
in textcontent div link not appear. link below , code copied post convenience. suggestions? i'm open other ideas, fade effect cool , keep that! assistance!
http://jsfiddle.net/mplungjan/bwd4v/
<style type="text/css"> div.textcontent { display:none } </style> <div id="textmessage"></div> <div class="textcontent">test line 1 </div> <div class="textcontent">test line 2</div> <script> var cnt=0, texts=[]; // save texts in array re-use $(".textcontent").each(function() { texts[cnt++]=$(this).text(); }); function slide() { if (cnt>=texts.length) cnt=0; $('#textmessage').html(texts[cnt++]); $('#textmessage') .fadein('slow').animate({opacity: 1.0}, 5000).fadeout('slow', function() { return slide() } ); } slide() </script>
you need use "html" instead of "text":
var cnt=0, texts=[]; // save texts in array re-use $(".textcontent").each(function() { texts[cnt++]=$(this).html(); }); function slide() { if (cnt>=texts.length) cnt=0; $('#textmessage').html(texts[cnt++]); $('#textmessage') .fadein('slow').animate({opacity: 1.0}, 5000).fadeout('slow', function() { return slide() } ); } slide()
fiddle: http://jsfiddle.net/bwd4v/132/
Comments
Post a Comment