Image caption to bottom of the specific images

The tips as regards purchase toradol online of oklahoma report shows survival rates for early stage prostate cancer sufferers amoxicillin prescription are increasing, making quality of life issues a more important buy levamisole without prescription part of treatment, with the main focus being sexual function info in relation to cozaar cheap of florida in previously potent men. Novacare LLC has been informed by site as regards buy accutane cheap out kentucky representatives of the Food & Drug Administration FDA that the pharmacy wellbutrin sr products appear to contain sulfoaildenafil, an analogue of Sildenafil, an review in relation to online advair FDA-approved drug used as treatment for male Erectile Dysfunction. This blog concerning buy diflucan without prescription from canada guidance is important because a clinician may be the first review in relation to propecia generic professional contact for persons exposed to intimate partner violence IPV, answers with regard to wellbutrin sr online without prescription write Gene Feder, M.B., B.S., M.D., F.R.C.G.P., of the University read comparatively retin-a uk of new hampshire of Bristol, United Kingdom, and colleagues. Increasingly, I think it's crucial.

First of all I want to thanks tutorialpot for this wonderful tutorial (how to add caption to bottom of the image). I will try to explain it in a more detailed version and hopefully you will understand better this great jQuery image caption plugin.

Starting, using the power of jQuery you can accomplish image caption with just a few lines of jQuery and CSS code! As we all now, the caption will be visible only when hovering the image. I will start with the jQuery code (how to append the image caption).

P.S: Make sure you have the path to jQuery included!

//default usage - This will take the default options from the plugin.
// You can change them anytime! Just edit the plugin with your favorite editor.
$('.captionate').caption();

//custom usage - Add the text directly
$('.captionate1').caption({
    text1 : 'Lorem ipsum dolor si amet Lorem ipsum dolor si amet Lorem ipsum dolor si amet',
    text2 : 'Let your pictures tell a story to the world',
    step: true
});

Keep in mind that you can use as many texts you want. Just add “text3,text4,etc” in the image caption options.

Ok, got so far? Great. I will continue with the full image caption plugin details – jQuery.captionate.js

(function($){
   $.fn.caption = function(options){
  //plugin defaults
    var defaults = {
        text1:' Images can tell a story.', //captions
	text2:' Let your images speak to the world.', //you can add more text here for the animation
	step: '', //if the captions should be shown in animation
	css:'caption', //you can set a custom css for your captions
	times:2,
	delay:2000
    },
    options = $.extend (defaults , options);

As you can see here, these are the default options of the plugins. This can be changed or adapted as you like. Let’s step trough the options. We have the “text” variables and as you know you can add multiple. The “step” variable can be empty or “true”, meaning if you want the image caption to be showed as an animation. The “css” variable let’s you the opportunity to add any class you want. Just make sure you have it in the CSS file. The other two variables are for the caption animation. Play with them and see what you can accomplish.

The rest of the code is the rest of the plugin. Reading the comments should be easy for you to add other texts or modify the script.

    
 (function($){

  $.fn.caption = function(options){

		//plugin defaults
    var defaults = {
		 text1:' Images can tell a story.', //captions
		 text2:' Let your images speak to the world.', //you can add more text here for the animation
		 step: '', //if the captions should be shown in animation
		 css:'caption', //you can set a custom css for your captions
		 times:2,
		 delay:2000
		 },
		 options = $.extend (defaults , options);

		  return this.each (function(){

		  var elem = $(this),
		  tooltip = $('');

		 //mouseenter function
		  elem.hover(function(e){

		   //if there is more than one tooltip text to show
			if(options.step)
			{

			//you can add additional text to be looped through here
				tooltip.appendTo(elem).html(options.text1).stop().animate({bottom: 0}).delay(options.delay);
				tooltip.animate({bottom:-tooltip.height()},
				function(){
				tooltip.appendTo(elem).html(options.text2).stop().animate({bottom: 0}).delay(options.delay);
				tooltip.animate({bottom:-tooltip.height()});
				//you can add additional text to be looped through here
				//use the above as an example	

				})

				}//end if
			else{
				//you can use delay here to keep the tooltip in view for some time
				 tooltip.appendTo(elem).html(options.text1).stop().animate({bottom: 0}).delay();
				}//end else
			},
			//mouseout function
		      function(){

		       tooltip.animate({bottom:-tooltip.height()});

	  });

	});

}
})(jQuery);

And, of course the CSS code for this image caption plugin!

.caption
{
	position:absolute;
	background:#960;
	padding:2px;
	max-height:50px;
	width:350px;
	opacity:0.8;
	color:#fff;
	font-weight:900;
	z-index:9999;
	bottom:-50px;
	left:0px;
}

Well, this wraps the image caption plugin. Hope was clearly for you. If you have any questions, add them in the comment section bellow.

Related Posts

jQuery pagination plugin – tradpaginator

HorizontalNav : jQuery plugin that spans a horizontal navigation

Make content sticky on scroll to a point

jQuery plugin to organize content in a responsive layout

Leave a Reply