Reputation: 21
I need to put some caption in my images with lightbox plugin, it calls the caption with the function below:
setCaption: function () {
var caption = $(plugin.current).data("caption");
if(!!caption && caption.length > 0) {
plugin.caption.fadeIn();
$('p', plugin.caption).text(caption);
}else{
plugin.caption.hide();
}
},
I don't know the place in html that i have to type the caption to the function get it, could you help me?
Upvotes: 2
Views: 40
Reputation: 17370
Say the plugin.current
element is a <span>
then you do something like:
<span data-caption="My caption">Hello, World!</span>
The convention for .data
will look for data attributes on an element. The preface data-
is the indicator, and the suffix, caption
is the name in this case, hence data-caption
.
Upvotes: 2