I am trying to display content on the window resize and load. After that clicking table th attribute is equal to the given value. I don't know where I am doing wrong but I am unable to get the result.
$(window).on("load resize", function(e) {
var $theWindowSize = $(this).width();
if ($theWindowSize < 768) {
alert($theWindowSize);
if ($('table th').attr('id') == 'basic-tab') {
$('table th#basic-tab').on('click', function(e) {
alert('basic');
$('table .basic-content').css('display', 'block');
});
} else if ($('table th').attr('id') == 'standard-tab') {
$('table th#standard-tab').on('click', function(e) {
alert('standard');
$('table .standard-content').css('display', 'block');
});
}
}
});
.basic-content,
.standard-content {
dispaly: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
<th id="basic-tab">Tab1</th>
<th id="standard-tab">Tab2</th>
</tr>
<tr class="basic-content">
<td>Basic Content</td>
</tr>
<tr class="standard-content">
<td>Standard Content</td>
</tr>
</table>
$('table .content').css('display','block');