Jump to content

JQuery question


balkan7

Recommended Posts

i use jquery message ticker to display the message, but whether it is possible that the new messages to display without refresh with jQuery?

 

jquery.js

(function($) {
$.fn.SmS = $.fn.sms = function(delay)
{
delay = delay || 4000;
initTicker = function(el)
{
	stopTicker(el);
	el.items = $("li", el);
	// hide all items (except first one)
	el.items.not(":eq(0)").hide().end();
	// current item
	el.currentitem = 0;
	startTicker(el);
};
startTicker = function(el)
{
	el.tickfn = setInterval(function() { doTick(el) }, delay)
};
stopTicker = function(el)
{
	clearInterval(el.tickfn);
};
pauseTicker = function(el)
{
	el.pause = true;
};
resumeTicker = function(el)
{
	el.pause = false;
};
doTick = function(el)
{
	// don't run if paused
	if(el.pause) return;
	// pause until animation has finished
	el.pause = true;
	// hide current item
	$(el.items[el.currentitem]).fadeOut("slow",
		function()
		{
			$(this).hide();
			// move to next item and show
			el.currentitem = ++el.currentitem % (el.items.size());
			$(el.items[el.currentitem]).fadeIn("slow",
				function()
				{
					el.pause = false;
				}
			);
		}
	);
};
this.each(
	function()
	{
		if(this.nodeName.toLowerCase()!= "ul") return;
		initTicker(this);
	}
)
.addClass("sms")
.hover(
	function()
	{
		// pause if hovered over
		pauseTicker(this);
	},
	function()
	{
		// resume when not hovered over
		resumeTicker(this);
	}
);
return this;
};

})(jQuery);

 

test.html

<script type='text/javascript'>
$(document).ready(
	function() {
		$('#sms').SmS();
		$('#sms').show('fast');
     });
	}
);
</script>
<div id='sms'></div>

Link to comment
https://forums.phpfreaks.com/topic/154657-jquery-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.