I have menu that some of its li is hide.I have a table and I want when I click on every tr that li of menu was hide are become show and when I click out side of table ,the li of menu are shown are become hide.but my code do not work correctly when I click out side of my table and I comment relevant section for it in javasscript .the menu donot become hide.
https://codepen.io/anon/pen/mGJKvY
<div class="menu-header2">
<ul>
<li>upload</li>
<li class="itemMenu hide"><a href="#">download</a></li>
<li class="itemMenu hide"><a href="#" >delete</a></li>
</ul>
</div>
<table class="table my-table">
<thead>
<tr>
<th>name</th>
<th>size</th>
</tr>
</thead>
<tbody>
<tr>
<td>word2016</td>
<td>574 KB</td>
</tr>
<tr>
<td>power2016</td>
<td>574 KB</td>
</tr>
</tbody>
</table>
<style>
.hide{ display:none;}
.show{display:block}
</style>
<script>
$(document).ready(function () {
$(".my-table tbody > tr").click(function (e) {
//if (e.target !== this) {
// $(".menu-header2 .itemMenu").removeClass("show").addClass("hide");
// }
var item = $(this);
item.addClass("selected2");
$(".menu-header2 .itemMenu").removeClass("hide").addClass("show");
$(".my-table tbody > tr").not(item).removeClass("selected2");
});
});
</script>