Link to home
Start Free TrialLog in
Avatar of garyilm
garyilm

asked on

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() == "-") {
        $(source).html("+");
        viewContainer.hide();
    }
    else {
        $(source).html("-");
        viewContainer.show();
    }
}
    </script>


<a href="javascript:togglePanelMore('#row<%=i+1%>', '#togglerow<%=i+1%>')" id="togglerow<%=i+1%>">+</a>
Avatar of StingRaY
StingRaY
Flag of Thailand image

$(document).ready(function(){
    // define your sub selector here
    var subselector = '[id^="row"]';  // all sub with id starting with "row"
    $(subselector).hide();
});

Open in new window

Add

$(thenext).hide();

At the beginning of your script, this will hide the row by default.
ASKER CERTIFIED SOLUTION
Avatar of Proculopsis
Proculopsis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial