Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple Nav Issue involving jQuery's .show() function
    primarykey
    data
    text
    <p>Hi I have a mini nav how do I make it so for example if you click on #HOG and #CAT (#green) is showing it will show #red (#HOG) but if you click on #HOG and #red is showing it will hide #red, sorry I don't know how to explain it better I hope you understand what I mean, Sorry :-)</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Toggle&lt;/title&gt; &lt;meta charset="UTF-8"&gt; &lt;link rel="stylesheet" type="text/css" href="css/style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Hog&lt;/h1&gt; &lt;div id="container"&gt; &lt;div id="menu"&gt; &lt;div id="HOG"&gt;&lt;/div&gt; &lt;div id="DOG"&gt;&lt;/div&gt; &lt;div id="CAT"&gt;&lt;/div&gt; &lt;div id="red"&gt;&lt;/div&gt; &lt;div id="blue"&gt;&lt;/div&gt; &lt;div id="green"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="jquery-1.8.3.js"&gt;&lt;/script&gt; &lt;script src="main.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My CSS:</p> <pre><code>#container { width: 30em; height: 20em; background-color: #ccc; position: relative; } #HOG { width: 10em; height: 10em; background-color: red; float: left; display: block; } #DOG { width: 10em; height: 10em; background-color: blue; float: left; display: block; } #CAT { width: 10em; height: 10em; background-color: green; float: left; display: block; } #red { width: 30em; height: 10em; background-color: red; clear: both; display: none; } #blue { width: 30em; height: 10em; background-color: blue; clear: both; display: none; } #green { width: 30em; height: 10em; background-color: green; clear: both; display: none; } </code></pre> <p>My Javascript:</p> <pre><code>$(function() // run after page loads { $("#HOG").toggle(function() { // first click hides login form, shows password recovery $("#red").show(); $("#blue").hide(); $("#green").hide(); }, function() { // next click shows login form, hides password recovery $("#red").show(); $("#blue").hide(); $("#green").hide(); }); }); $(function() // run after page loads { $("#DOG").toggle(function() { // first click hides login form, shows password recovery $("#red").hide(); $("#blue").show(); $("#green").hide(); }, function() { // next click shows login form, hides password recovery $("#red").hide(); $("#blue").show(); $("#green").hide(); }); }); $(function() // run after page loads { $("#CAT").toggle(function() { // first click hides login form, shows password recovery $("#red").hide(); $("#blue").hide(); $("#green").show(); }, function() { // next click shows login form, hides password recovery $("#red").hide(); $("#blue").hide(); $("#green").show(); }); }); </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.
    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