How to hide an element after clicking it's child element using JavaScript

61 views Asked by At

I want to hide ul.media-boxes-drop-down-menu area after clicking any menu http://prntscr.com/7j5rmz item. I was tried many times with different different codes. But I was unable to solve it. Any one can help me how may I do it?

Thanks in advance.

2

There are 2 answers

3
Sajal On

Your question is ambiguous. from what i have understood.

<ul id="ul_1">
<li >Some text</li>
</ul>   


<ul class="active" id="ul_2">
<li >Some text</li>
</ul>

clicking on ul_1 will hide ul_2, refactor the code according to your need.

 $('#ul_1').on('click', function (e) {
        $('#ul_2').each(function () {
            $(this).removeClass('active');
        })
    });
0
rajeev kumar On

you have to give a class to that element you want to hide and then on-click() event you have to search that element inside wrapper main div like:

$('.elementTohode',$(this).parent().parent()).css('display','none')