Jquery show/hide: start with show instead of hide

Hi there folks!

In my effort to fit more stuff on smaller screens, I’m trying out jquery to hide tables on a page. Very early in my testing, it’s looking promising, but I’m having a problem figuring out how to have my first show/hide start out showing instead of hiding. Here’s the jquery that I’m using:

<script type='text/javascript'> $(document).ready(function(){ $('.table1').hide().before('<a href=\"#\" id=\"toggle-table1\"><h3 class=\"shadowy\">Automatic Bans</h3></a>'); $('a#toggle-table1').click(function() { $('.table1').slideToggle(1000); return false; }); }); </script>

Could someone point me in the right direction?

Thanks for your time!

Is it as easy as removing the .hide() part from the script?

Not to be stupid, but why run the jquery at all if you’re going to be showing it - isn’t that expected, default behavior. Why force the browser to do something it does natively?

I was hoping to modify the jquery to hide any open when opening a new one, keeping the page from growing to the point of unwieldiness.

Thanks very much Paul. I had tried it but had left the wrong ., causing a space where there shouldn’t have been. Display now works as hoped.

I haven’t figured out the text swapping properties on the button or the “close all but this” portion of my plan, but have some more threads to mine before asking about it.

Thanks everyone!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.