Note that there are some explanatory texts on larger screens.

plurals
  1. POShow/hide a div with jquery multiple times
    text
    copied!<p>I am wanting to use jquery to do a show/hide of a DIV from a text link. </p> <p>What makes it a little different from the examples I have found of this site so far is I need a generic way of doing it multiple times on 1 page and also able to use it sitewide on anypage. </p> <p>It would be really nice if I can put the JS in seperate file that is included into the pages, so maybe it can be wrapped into a function? </p> <p>Can someone help me here? For making it generic it could be where I assign a div that is shown/hidden with an id like <strong>id="toggle-hide-1"</strong> and just change the numbers in my page to make it a different show/hide area </p> <p>I could just name the ID using a name that will make the function show/hide a div and to seperate it from other divs that show/hide on a page I could add a number to it.</p> <p>below is partial code that will do a show/hide of a div on a link click but is not exactly what I need.</p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" &gt; $(function() { $(".view-code").click(function(evt) { $(".tool_block, .view-code").toggle(); }); }); &lt;/script&gt; &lt;a href="#" class="view-code" &gt;view code&lt;/a&gt; &lt;a href="#" class="view-code" style="display:none"&gt;hide code&lt;/a&gt; &lt;br /&gt; &lt;div class="tool_block" style="display:none" &gt; this stuff is hidden until we choose to show it! &lt;/div&gt; </code></pre>
 

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