jQuery ContentHover Plugin
ContentHover is a small jQuery plugin that helps you show some hidden content on top of an element when the mouse hovers over it. There are options to chose how your hover effect would appear, like fade in or slide in from any direction, you can change the opacity of the overlay etc. (Check out the options below)
Usage
Lets assume you have an image and want to show some text on top of it when the mouse hover over it.
Add a div with class="contenthover" after the image:
<img class="myimage" src="image.jpg" width="300" height="240" /> <div class="contenthover" style="padding:20px">This would show on top of my image on mouseover.</div>
Then fire the plugin like this: (using the default options)
<script>
$(function(){
$('.myimage').contenthover();
});
</script>
It doesn't always have to be an image and a div. It would work with any html element.
For demos check Examples & Usage.
Options reference
Here's the default options object with an explanation on every available option.
data_selector: '.contenthover', // The selector for the element that will be the content of the overlay element to show on hover
width: 0, // Set to 0 to let the plugin figure it out
height: 0, // Set to 0 to let the plugin figure it out
overlay_width: 0, // The overlay element's width. Set to 0 to use the same as 'width'
overlay_height: 0, // The overlay element's height. Set to 0 to use the same as 'height'
overlay_x_position: 'center', // [center, left, right] The position of the overlay horizontally (if overlay_width is different from width)
overlay_y_position: 'bottom', // [center, top, bottom] The position of the overlay vertically (if overlay_width is different from width)
overlay_background: '', // The css background of the overlay element
overlay_opacity: 1, // [0-1] The opacity of the overlay element
effect: 'fade', // [fade, slide, show] The effect to use
fade_speed: 400, // Effect ducation for the 'fade' effect only
slide_speed: 400, // Effect ducation for the 'slide' effect only
slide_direction: 'bottom', // [top, bottom, right, left] From which direction should the overlay apear, for the slide effect only
zindex: 2, // The base z-index value
wrapper_class: 'ch_wrapper', // CSS class to add to the wrapper
normal_class: 'ch_normal', // CSS class to add to the 'normal' element
hover_class: 'ch_hover', // CSS class to add to the 'hover' element
onshow: function(){}, // Callback function when the 'hover' element is shown
onhide: function(){} // Callback function when the 'hover' element is hidden
Compatibility
It has been tested on the latest versions of Firefox, Chrome, IE and Opera and seems to work well. It also works on IE7, 8 and 9. It does not make use of any CSS3 transitions and effects, so the result should be similar on most browsers.
To-do
- Bug fixing
- Add more effects
Feel free to comment or report any bug.





Tuscany Villas • January 19, 2012 11:02
Ss • February 17, 2012 15:04
just one issue, if you use cufon for the content in the hidden div, text that uses cufon does not show up.
any suggestions?
cheerio,
S.
Nikos Tsaganos • February 21, 2012 20:56
BD Design • May 21, 2012 03:24
Here's an effect suggestion for any future updates you might release. Have an option where the background slides in from a different direction than the content layer - for example the background slides from top to center and the content slides from bottom to center. The only example I could find is the wild is the second example ('Theme Two') from this plugin on ThemeForest: http://tinyurl.com/7oofkcg
Thanks again!
BD
Daniel Watson • June 7, 2012 13:49
Thank you for the article
Qasim • July 27, 2012 21:14
I'm having trouble implementing this in Wordpress. It's usually pretty simple with other jQuery plugins I've used.
I've copied the HTML code into a new page, loaded up the js file. I already have the jQuery library loaded in my site, and copied in the jQuery for the simple fade. Nothing. It's just the image that shows. Google Chrome shows no errors.
I have to say I'm not a pro at this, so am I doing something wrong?
Thanks so much.
henry • August 9, 2012 02:34
Pat • August 9, 2012 22:18
Pat • August 9, 2012 22:23
copy the style you want and give it another name - $('#d7') , $('#d8') etc
henry • August 13, 2012 11:48
Thanks for your reply but I am generating a dynamic images from the database using the url so I think it will be better to use a simple class or Id name to wrapper many photos together just like in gallery so all of them will have same effect.
Looking forward to read from you.
Once again thanks so much
henry • August 14, 2012 15:40
If you have a solution to my question as it regards my project requirement, please kindly let me know because I am struggling with that issue with your plugin and it is delaying my project.
Thanks so much
tiffany • August 20, 2012 09:35
However, I'm coming across one issue – the image to be swapped on my page doesn't display on page load and only appears when the page is refreshed.
Do you have any ideas for how to fix this?
Thanks in advance!
tiffany • August 21, 2012 08:26
Michael Caputo • August 21, 2012 18:21
Marta Johnsson • September 12, 2012 02:17
julieth • September 17, 2012 13:20
Ben • October 12, 2012 06:17
I can not seem to get a series of these elements to appear inline. Is there a way to do this? Adding #d1 {display:inline} only breaks the code
Haitham • October 12, 2012 08:05
or if you know an alternative to this that's responsive.
J3.14R • November 5, 2012 23:54
enki • November 8, 2012 17:15
I have two div/boxes inside a container.
I want to apply the contenthover script to the first box but when i do that the second box on the right goes down on the left and dont stay on the same level on the right :(
The padding is 0, but impossible to have the 2 boxes at the same leve. Any idea? (sorry if my english is not perfect)
Manni • November 9, 2012 15:56
mike • November 16, 2012 04:18
amrabdelaziz • November 17, 2012 14:31
Barbara • December 3, 2012 23:15
Alex • December 4, 2012 20:05
thanks for this nice plugin.
One thing i have problems with is that when i hit refresh in Safari and Chrome and Ctrl+Shift R in Firefox, the site reloads an the images disapeared. Another refresh does not get them back. If i navigate through a link or the addressfield to the site, it works fine.
Any ideas?
best regards
Wyneth • December 10, 2012 12:44
Andrew • December 15, 2012 13:53
$(".ch_element").css("float", "left").css("marginLeft", "20px").css("marginTop", "20px");
(or whatever styling you want to apply)
Other than that, the plug in is great - credit and thanks to Nikos for taking the time to provide this to us all.
Rob • December 25, 2012 19:18
Any help would be greatly appreciated, Thanx R
Barbara • December 28, 2012 20:45
I'm using a png for the overlay as shown in one of the demos. In IE8, there is this flash of solid black before the overlay image png kicks in. Of course, it doesn't happen in any other browser.
Any idea how I can work around this
matt • January 6, 2013 06:36
matt • January 6, 2013 06:36
Karanvir Kang • January 15, 2013 17:41
Can you please tell me the licensing details of this plugin ?
web design • January 18, 2013 15:36
Jaume Juan • January 28, 2013 14:42
I'e a problem, I have several images in one div and the plugin only works in the first. I can't find the solution. Anybody knows what is the problem?
Thanks
Jeff Paulson • January 31, 2013 11:49
Carlos Barrionuevo • February 6, 2013 01:22
santosh • February 14, 2013 08:00
Richy • March 7, 2013 19:32
Daniel Mariluz • March 15, 2013 23:05
If you want to apply the same effect to several images, it defines a class instead of an ID so that it can be repetitive.
Greetings from Peru
Mika Douglas • April 4, 2013 03:26
I am a novice but I think I can handle the css and the html.
I have never added a plugin short of the automated way. How and where do I add the javascript?
Thanks
John Bustamante • April 22, 2013 04:19
romane • May 1, 2013 19:34
romane • May 1, 2013 19:36
Carlos Barrionuevo • May 20, 2013 19:01