Today we will learn how to get simple toggle effect on hover/click with jQuery. We will use Css and Jquery to get our final output. Check out the demo before getting into the tutorial.
Demo
Step 1 : HTML
So now we will document our page. First of all we need heading and toggle box for hide and show. Check out the below html code to get it clear.
<h2>Move Cursor</h2> <div class="togglebox"> <div class="content"> <h3>Content Here</h3> <!--Content Here--></div> </div>
Step 2 : Styling our HTML document
Now we need to style our html elements like heading, togglebox and content. See the codes below.
h2 { padding:10px; font-size:20px; color:#243953; background-color:#fafafa; border: 1px solid #a9a9a9; -moz-border-radius: 7px; /* Rounder Corner */ -webkit-border-radius: 7px; -khtml-border-radius: 7px; text-align:center; font-family:Georgia, "Times New Roman", Times, serif; margin-bottom:5px; } .togglebox { background-color:#CCC; border: 1px solid #a9a9a9; /* Rounder Corner */ -moz-border-radius: 7px; -webkit-border-radius: 7px; -khtml-border-radius: 7px; overflow: hidden; font-size: 1.2em; width: 295px; clear: both; margin-bottom:10px; } .togglebox .content { padding: 20px; }
Step 3 : Jquery Time
Create a new JS file and then Link Jquery and new js file to Html document
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"><!--mce:0--></script> <script src="toggle.js" type="text/javascript"><!--mce:1--></script>
Now to give some smoth toggle effect we need to write some simple jquery code to give it a life. Below are the codes with explanation.
Toggle effect on hover
$(document).ready(function(){ //Hide the tooglebox when page load $(".togglebox").hide(); //slide up and down when hover over heading 2 $("h2").hover(function(){ // slide toggle effect set to slow you can set it to fast too. $(this).next(".togglebox").slideToggle("slow"); return true; }); });
Toggle effect on click
$(document).ready(function(){ //Hide the tooglebox when page load $(".togglebox").hide(); //slide up and down when click over heading 2 $("h2").click(function(){ // slide toggle effect set to slow you can set it to fast too. $(this).next(".togglebox").slideToggle("slow"); return true; }); });

















Social comments and analytics for this post…
This post was mentioned on Twitter by CreativityGeek: Acris Design – Jquery Tutorial : Toggle Effect on Hover/Click http://bit.ly/9Dqa7z…
[...] Continued here: Jquery Tutorial : Toggle Effect on Hover/Click | AcrisDesign [...]
You should solve the problem with queue effect , .stop() I think will help
wow… it is really cool. Good work, mate
[...] Here is the original post: Jquery Tutorial : Toggle Effect on Hover or Click [...]
[...] View post: Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign [...]
[...] Jquery Tutorial: Toggle Effect on Hover/Click – http://bit.ly/cvFq1q [...]
[...] Go here to read the rest: Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign [...]
[...] (64) JQuery tutorial: efecto hover activar / clic [...]
[...] Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign [...]
[...] Jquery Tutorial : Toggle Effect on Hover/Click [...]
Jquery Tutorial : Toggle Effect on Hover/Click …
Today we will learn how to get simple toggle effect on hover/click with jQuery. We will use Css and Jquery to get our final output….
[...] Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign [...]
[...] Jquery Tutorial : Toggle Effect on Hover/Click [...]
[...] Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign [...]
Great tutorial, the .hover() function in jQuery is really useful. In some instances, I’ve found it best to use the jQuery hoverintent plugin to hide/show things since sometimes if a user hovers over lots of elements it can be confusing and distracting to them.
http://cherne.net/brian/resources/jquery.hoverIntent.html
Good Job
[...] Link: Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign [...]
[...] jQuery Tutorial : Toggle Effect on Hover or Click [...]
[...] jQuery Tutorial : Toggle Effect on Hover or Click jQuery Tutorial : Toggle Effect on Hover or Click [...]
[...] Tutorial by Acris Design. Works great for FAQ [...]
[...] jQuery Tutorial : Toggle Effect on Hover or Click Filed in Tutorial, Uncategorized, jQuery Posted by Jon Phillips Tagged Design, jQuery, toggle, Tutorial blog.lanche86.com is powered by WordPress using theme Tribune [...]
[...] Jquery Tutorial : Toggle Effect on Hover/Click [...]
[...] Jquery Tutorial : Toggle Effect on Hover/Click [...]
[...] Jquery Tutorial : Toggle Effect on Hover/Click [...]
[...] Jquery Tutorial : Toggle Effect on Hover/Click [...]
rocking information, friend thanks for this
Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign
Hi,
I use your toggle effect onClick to show and hide a small gallery with a couple of pictures inside and it work perfect but i was wondering if you can help me to make done one small thing more. and it’s that would like to move up/down too the footer of the page so it doesn’t look so big when all is close it? any idea or help on this?
regards
mbarcala
Jquery Tutorial : Toggle Effect on Hover or Click…
Today we will learn how to get simple toggle effect on hover/click with jQuery. We will use Css and Jquery to get our final output….
I like the way you have it laid out, Diabete Diabete
Great tutorial, the .hover() function in jQuery is really useful. In some instances, I’ve found it best to use the jQuery hoverintent plugin to hide/show things since sometimes if a user hovers over lots of elements it can be confusing and distracting to them.
vítores Malo, muy usar la información completa. Gracias.
Jquery Tutorial : Toggle Effect on Hover or Click | AcrisDesign
Dude! thanks a bunch. i tried so many jquery effects to hide a certain things in my blog but this is only the one tht worked perfectly.
I have some question.. how can I make the content when i mouseover on it it will stays in place?
Thanks for your toggle menu. Its very simple and easy to use.