Skip to content

Instantly share code, notes, and snippets.

@chris-jamieson
Last active December 25, 2016 23:24
Show Gist options
  • Save chris-jamieson/5477085 to your computer and use it in GitHub Desktop.
Save chris-jamieson/5477085 to your computer and use it in GitHub Desktop.
Simple jQuery snippet to set the title attribute of an <img> as a caption
$(document).ready(function() {
$("img").each(function () {
var $this = $(this);
var title = $this.attr("title");
$this.after('<div class="caption">'+ title +'</div>');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment