Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Add a caption to any image relying only on the image's 'alt' attribute.
JavaScript
branch: master
Failed to load latest commit information.
css build on demo
img build on demo
js build on demo
README.md adjust readme
demo.html build on demo

README.md

jquery.caption

jQuery.caption is a simple plugin which displays an image's 'alt' attribute content, using HTML5's 'figure' and 'figcaption' elements.

Compatibility

This plugin uses the latest jQuery.

The figure and figcaption elements are supported in Internet Explorer 9, Firefox, Opera, Chrome, and Safari.

Usage

$('img').caption();

// or with options

$('img').caption({'visible':true});

Resulting HTML

Before

<img src="img/kho-maak.jpg" alt="kho Maak - A small island in Thailand"/>

After

<figure class="figure">
    <img src="img/kho-maak.jpg" alt="kho Maak - A small island in Thailand"/>
    <figcaption class="figcaption">
        <em>kho Maak</em>
        <br>
        A small island in Thailand
    </figcaption>
</figure>

Options

figureClass     {string}    default:'figure'        The css class of the 'figure' element.
figcaptionClass {string}    default:'figcaption'    The css class of the 'figcaption' element.
lineBreak       {string}    default:' - '           A string that is converted to a regular expression and used to delimit a line in the 'alt' attribute.
visible         {boolean}   default:false           Whether or not the figcaption is initially displayed.
Something went wrong with that request. Please try again.