/ Published in: jQuery
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
(function($) {
$.fn.jwNotice = function(options) {
var options = $.extend({
className : 'notice',
text : null,
siteWidth : null
}, options);
return this.each(function() {
$(this).prepend('<div class="' + options.className + '" />');
var $announceDiv = $('.' + options.className);
$announceDiv
.append('<div>' + options.text + '</div>')
.children('> div')
.css({
'width' : options.siteWidth,
'margin' : 'auto'
})
.end()
.prepend('<span class="close">X</span>')
.children('.close')
.css({
'position' : 'absolute',
'cursor' : 'pointer',
'display' : 'none'
})
.end()
.hover(function() {
// over
$(this)
.children('span.close')
.show()
.click(function() {
$announceDiv.slideUp(250, function() {
$(this).remove();
});
});
}, function() {
// out
$('.close').hide();
});
}); // end each
}
})(jQuery);
Comments
 Subscribe to comments
                    Subscribe to comments
                
                