(function($){ $.fn.msg = function() { var obj = this; var win = function(id_win,e,title){ $win = $('
'); $win.css({ 'border-radius': 5 + 'px' ,'-moz-border-radius': 5 + 'px' ,'-webkit-border-radius': 5 + 'px' }); var cnt = '
'; if($(e).attr('href')!="#")cnt += ' '; cnt += title; cnt += '
'; $content = $(cnt); $close = $('
'); $($close).bind('click',function(){ $($win).hide(); }); offSetTop = $(e).offset().top - 150; offSetLeft = $(e).offset().left + $(e).outerWidth() - 115; $win.css({'top' : offSetTop + 'px', 'left' : offSetLeft + 'px'}); $($win).append($close); $($win).append($content); $('body').append($win); } var find = function(){ $(obj).each(function (i) { var href = $(this).attr('href'); var title = $(this).attr('title'); var id_win = 'msg_win'+i; $(this).bind('click',function(){ $('.win').remove(); win(id_win,this,title); return false; }) }) } var close = function(id){ $('#tip_close').bind('click',function(){ $('#'+id).remove(); }); } find(); }; })(jQuery); $(function(){ $("a[rel~='msg']").msg(); })