Skip to content

Instantly share code, notes, and snippets.

@japsu
Last active August 27, 2015 20:21
Show Gist options
  • Save japsu/2c2b4760290a17859b66 to your computer and use it in GitHub Desktop.
Save japsu/2c2b4760290a17859b66 to your computer and use it in GitHub Desktop.
Show img[alt] in a Bootstrap 3 popover without any extra markup (doesn't break floats etc)
(function($) {
$('img[alt]').each(function() {
var $this = $(this);
$this
.attr('data-content', $this.attr('alt'))
.hover(function() {
$(this).popover('show');
}, function() {
$(this).popover('hide');
});
}).popover({
trigger: 'manual',
placement: 'bottom auto',
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment