Jquery Hide

I have a dynamic table with a toggle show row. When the page loads the sub rows are visiable. How do I make them hidden until I expand them. Here is the code that I am working with.

<script type="text/javascript">

        function togglePanelMore(thenext, source) {
    var viewContainer = $(thenext);
    if ($(source).html() == "-") {
    else {

<a href="javascript:togglePanelMore('#row<%=i+1%>', '#togglerow<%=i+1%>')" id="togglerow<%=i+1%>">+</a>
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

    // define your sub selector here
    var subselector = '[id^="row"]';  // all sub with id starting with "row"

Open in new window



At the beginning of your script, this will hide the row by default.

Is something like this of any use:

<meta http-equiv="X-UA-Compatible" content="IE=8" />
<script type="text/javascript" src="http://filedb.experts-exchange.com/incoming/2011/05_w20/458595/jquery-1.5.2.min.js"></script>

jQuery(document).ready( function() {

  $(".expand").each( function() {
    var group = $(this).attr("group");
    $(this).click( function() {
      $(this).text( ( $(this).text() == "+" )? "-": "+" );
      toggle( group );
    toggle( group );
    $(this).css( {textDecoration: "none"} );

  function toggle( group ) {
    $("tr[rel=" + group).toggle();




<table border="1">
<tr><td><a class="expand" href="#" group="group-a">+</a></td><td colspan="2">&larr; toggle rows</td></tr>
<tr rel="group-a"><td></td><td>some</td><td>stuff</td></tr>
<tr rel="group-a"><td></td><td>more</td><td>stuff</td></tr>
<tr rel="group-a"><td></td><td>other</td><td>stuff</td></tr>

<tr><td><a class="expand" href="#" group="group-b">+</a></td><td colspan="2">&larr; toggle rows</td></tr>
<tr rel="group-b"><td></td><td>some</td><td>stuff</td></tr>
<tr rel="group-b"><td></td><td>more</td><td>stuff</td></tr>
<tr rel="group-b"><td></td><td>other</td><td>stuff</td></tr>

<tr><td><a class="expand" href="#" group="group-c">+</a></td><td colspan="2">&larr; toggle rows</td></tr>
<tr rel="group-c"><td></td><td>some</td><td>stuff</td></tr>
<tr rel="group-c"><td></td><td>more</td><td>stuff</td></tr>
<tr rel="group-c"><td></td><td>other</td><td>stuff</td></tr>


Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.