Me gustaría compartir una solución mucho más. Se basa en widgets personalizados y permite agregar un título y un icono personalizable. Pruebe Fiddle o busque debajo:
$.widget('custom.noteBox', {
options: {
icon: true,
state: 'highlight'
},
_create: function() {
var icon, note = $('<p>').html(this.element.html());
if (this.options.icon === true) {
switch (this.options.state) {
case 'highlight':
icon = 'info';
break;
case 'error':
icon = 'alert';
break;
default:
icon = false;
}
} else {
icon = this.options.icon;
}
if (icon) note.prepend($('<span>')
.addClass('ui-icon ui-icon-' + icon)
.css({
'float': 'left',
'margin-right': '.3em'
}));
var title = this.element.attr('title');
if (title) note.prepend($('<strong>').text(title + ' '));
this.element.addClass('ui-widget')
.replaceWith($('<div>')
.addClass('ui-state-' + this.options.state + ' ui-corner-all')
.css({
'margin-top': '20px',
'padding': '0 .7em'
})
.append(note));
}
});
$('.error').noteBox({
state: 'error'
});
$('.info').noteBox();
$('<div title="Note! ">I`m dynamically added #1</div>')
.appendTo('body').noteBox({
icon: 'folder-open'
});
$('<div title="Note! ">I`m dynamically added #2</div>')
.appendTo('body').noteBox({
state: 'error'
});
$('<div title="Note! ">I`m dynamically added #3</div>')
.appendTo('body').noteBox({
state: 'error',
icon: 'trash'
});
Tu respuesta es lo suficientemente buena para ser elegida, creo que esto es correcto, pero echa un vistazo a este enlace que obtuve de irc gracias a 'ajpiano' - nunca lo vi antes de hoy http://wiki.jqueryui.com/jQuery -UI-CSS-Framework –
¡Dulce! Voy a Instapaper eso. – flipdoubt