Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery - .preventDefault()
    primarykey
    data
    text
    <p>Using the code below I have a hide show effect applied to some table cells that are also have their width expanded and collapsed. The problem is that when a link is clicked, all the text shows up, the table resizes then the text disappears. I would like the unclicked text to remain hidden throughout and not flash on screen. I think this might have something to do with preventDefault or return False but when I've tried these it has stopped the table from working at all after the first click. Really not sure what I'm doing wrong.</p> <p>As always, any help greatly appreciated.</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;Levels of Progression&lt;/title&gt; &lt;style&gt; body{font-family:Arial, Helvetica, sans-serif; font-size:80%;} table td{vertical-align:top; padding:5px;} table td div{width:80px; overflow:hidden; display:none;} table td .toggleSection1{width:200px; display:block;} .explore td{background:#c0da77;} #e1{color:#8BAD30; width:200px;} #express td{background:#cf7db4;} #e2{color:#cf7db4; } #exchange td{background:#58bccc;} #e3{color:#3AAABE;} #evaluate td{background:#ab91c4;} #e4{color:#8864AC;} #exhibit td{background:#f7b930;} #e5{color:#E3A209;} table td a{color:black; text-decoration:none; } table td a:hover{color:white; background:black; } table td.title{font-size:1.3em; font-weight:bold; padding-bottom:0; margin-bottom:0; vertical-align:bottom;} .levels{text-align:center; font-size:1.3em; font-weight:bold; background:#CCC; font-family:Georgia, "Times New Roman", Times, serif;} .title{ font-family:Georgia, "Times New Roman", Times, serif;} #exchange .none{color:white; color:#cdebf0; font-style:italic;} #evaluate .none{color:white; color:#e6deed; font-style:italic;} &lt;/style&gt; &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/thickbox.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ function showSlidingDiv(column){ var maxWidth = 200; var smallWidth = 80; var smallHeight = 50; var myWidth = $(column).width(); $("div").animate({width: smallWidth}, 400, function() { $(this).hide(); }); $(column).animate({width: maxWidth}, 400, function() { $(column).show(); }); } //]]&gt; &lt;/script&gt; &lt;/head&gt;&lt;body&gt; &lt;table width="800" border="0" cellspacing="5"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td class="levels"&gt;&lt;a href="" onClick="showSlidingDiv('.toggleSection1'); return false;"&gt;Level 1&lt;/a&gt;&lt;/td&gt; &lt;td class="levels "&gt;&lt;a href="" onClick="showSlidingDiv('.toggleSection2'); return false;"&gt;Level 2&lt;/a&gt;&lt;/td&gt; &lt;td class="levels "&gt;&lt;a href="" onClick="showSlidingDiv('.toggleSection3'); return false;"&gt;Level 3&lt;/a&gt;&lt;/td&gt; &lt;td class="levels "&gt;&lt;a href="" onClick="showSlidingDiv('.toggleSection4'); return false;"&gt;Level 4&lt;/a&gt;&lt;/td&gt; &lt;td class="levels "&gt;&lt;a href="" onClick="showSlidingDiv('.toggleSection5'); return false;"&gt;Level 5&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="title" id="e1"&gt;Explore&lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection1"&gt;Text here:&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection2"&gt;Text here:&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection3"&gt;Text here:&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection4"&gt;Text here:&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection5"&gt;Text here:&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="explore"&gt; &lt;td&gt;Some text in here &lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection1"&gt;find and select information from a given digital source;&lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection2"&gt;find, select and use information from a given digital source;&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection3"&gt;research, select, edit and use information from given digital sources;&lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection4"&gt; research, select, edit and use assets from a range of digital sources;&lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;div class="toggleSection5"&gt;research, select, edit, use and evaluate assets from a range of digital sources;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/body&gt;&lt;/html&gt; </code></pre>
    singulars
    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