Return to Snippet

Revision: 10131
at December 9, 2008 11:51 by stellit


Initial Code
var show = function (divId){
		var div = $j('#'+divId);
		div.show();
		div.focus();
		div.bind("mouseout",function(e){
			if (!e) var e = window.event;
			var tg = (window.event) ? e.srcElement : e.target;
			if (tg.nodeName != 'DIV') return;
			var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
			while (reltg != tg && reltg.nodeName != 'BODY')
				reltg= reltg.parentNode
			if (reltg== tg) return;
			$j(this).hide();
		});
	};


/***sample***/
html:
<div onmouseout="alert('oh no!! mouse left me alone...');">
    <a>evil element</a>
</div>

Initial URL

                                

Initial Description
mouse out event of a div will be triggered even mouse entered a element with in a div which we do not want it happen.
But all browsers are agree on it...

Initial Title
make your mouse out event works right

Initial Tags

                                

Initial Language
JavaScript