Note that there are some explanatory texts on larger screens.

plurals
  1. POToggeling jQuery hide/show
    primarykey
    data
    text
    <p>I have a navigation that I am using jQuery slideshow to expose the content under the Navigation. I got the div's to toggle when you click a different nav item, but when I click the same nav item to close it, it just bounces the tab closed then open again. I have a close button inside of the div that is closing it for now.</p> <p>How do I get a div to close once it's been opened></p> <p>Link to the example is <a href="http://www.jesseshowalter.com/dbd/" rel="nofollow">here</a></p> <p>My jQuery is as follows:</p> <pre><code>(function ($) { $.fn.showHide = function (options) { //default vars for the plugin var defaults = { speed: 1000, easing: '', changeText: 0, showText: 'Show', hideText: 'Hide' }; var options = $.extend(defaults, options); $(this).click(function () { $('.toggleDiv').slideUp(options.speed, options.easing); // this var stores which button you've clicked var toggleClick = $(this); // this reads the rel attribute of the button to determine which div id to toggle var toggleDiv = $(this).attr('rel'); // here we toggle show/hide the correct div at the right speed and using which easing effect $(toggleDiv).slideToggle(options.speed, options.easing, function() { // this only fires once the animation is completed if(options.changeText==1){ $(toggleDiv).is(":visible") ? toggleClick.text(options.hideText) : toggleClick.text(options.showText); } }); return false; }); }; })(jQuery); </code></pre> <p>and i am firing with:</p> <pre><code>$(document).ready(function(){ $('.show_hide').showHide({ speed: 300, // speed you want the toggle to happen easing: '', // the animation effect you want. Remove this line if you dont want an effect and if you haven't included jQuery UI changeText: 0, // if you dont want the button text to change, set this to 0 showText: 'View',// the button text to show when a div is closed hideText: 'Close' // the button text to show when a div is open }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload