[英]Make the table disappear with JavaScript
These are the Js and Html codes:这些是 Js 和 Html 代码:
function div(window.matchMedia("(max-width:800px)")) {
if (window.matchMedia("(min-width:800px)")) {
document.getElementById("invtable").style.display = "block";
} else {
document.getElementById("invtable").style.display = "none";
}
}
<div class="widget widget-table action-table" id="invtable">
<div class="widget-header"> <i class="icon-th-list"></i>
<h3>Últimos Podcasts</h3>
</div>
<!-- /widget-header -->
<div class="widget-content">
<table class="table table-striped table-bordered">
<thead>
<tr style="width:300px">
<th> Nº</th>
<th> Título da Postagem </th>
<th> DATA</th>
<th> Link</th>
<th> Descrição</th>
<th class="td-actions"> </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- /widget-content -->
</div>
I need this html table to disappear, as it does not respond to mobile devices.我需要这个 html 表消失,因为它不响应移动设备。
I tried to use window.matchMedia, which is equivalent to Media Queries, but unfortunately I didn't get the expected result.我尝试使用window.matchMedia,相当于Media Queries,可惜没有得到预期的结果。
You need to check for .matches
您需要检查
.matches
if (window.matchMedia("(min-width:800px)").matches) {
document.getElementById("invtable").style.display = "block";
} else {
document.getElementById("invtable").style.display = "none";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.