JavaScript jquery regex issue match any string a-zA-Z0-1

For some reaon, I cannot use nested div, and I m trying to toggle a tree of divs Div id contains any string except -

<div class="tree">
    <div id="a">id=a click to toggle child</div> 
        <div id="a-1"> == id=a-1</div>
            <div id="a-1-f"> == == id=a-1-f</div>
            <div id="a-1-g"> == == id=a-1-g</div>
        <div id="a-2"> == id=a-2</div>
    <div id="b">id=b</div>
</div>

$('.tree').children().on('click',function(){
    var $id = $(this).attr('id');
    $(this).parent().children().removeClass('on');
    $(this).toggleClass('on');
    $('[id^='+$id+'-]').hide();
    var str = /^[a-zA-Z0-9]*$/;
    if ($(this).hasClass('on')) {
        $('[id^='+$id+'-'+ str +']').show();
    }
});

what should i do for the str above in js

http://jsfiddle.net/cn856y49/4/

What I'm trying to do is: click on any div above: hide all its children and grandchildren, or show only its children.

Hide is working now. However I'm not sure how to make show working.

E.g.. click on id=a will hide all id=a-1, a-xx-xx etc, click on id=a again will only show its next level kids

Answer:1

I don't want to use the default, + icon, to expand the row. Clicking anywhere on the row should expand it. I tried this: HTML <div ui-grid="gridOptions" ui-grid-expandable class="grid"> ...

I don't want to use the default, + icon, to expand the row. Clicking anywhere on the row should expand it. I tried this: HTML <div ui-grid="gridOptions" ui-grid-expandable class="grid"> ...

  1. ui grid expandable grid example
  2. expandable grid ui-grid

I know it seems like a duplicate but it isn't. Nothing worked, whatever I tried. I have a list in my angular module: this.checkedInterviews = [] and then a function that does: var interviewModel = ...

I know it seems like a duplicate but it isn't. Nothing worked, whatever I tried. I have a list in my angular module: this.checkedInterviews = [] and then a function that does: var interviewModel = ...

I want to append div based on dragend event coordinates. This is what I have tried: $(document).ready(function () { var mouseX; var mouseY; $(document).mousemove(...

I want to append div based on dragend event coordinates. This is what I have tried: $(document).ready(function () { var mouseX; var mouseY; $(document).mousemove(...

I have succesfully implemented the DataTables (version 1.10+) pagination plugin with textbox but I would like to allow the user to first enter a page number and then to press the enter key. By default,...

I have succesfully implemented the DataTables (version 1.10+) pagination plugin with textbox but I would like to allow the user to first enter a page number and then to press the enter key. By default,...