1 回答
TA贡献1810条经验 获得超4个赞
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$(".show-text").toggleClass("show-table");
});
});
</script>
<style>
.show-text p{
display: block
}
.show-text table{
display: none
}
.show-text.show-table p{
display: none
}
.show-text.show-table table{
display: block
}
</style>
</head>
<body>
<div class="show-text">
<p>any text</p>
<table>
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
<button>toggle</button>
</body>
</html>
Js Fiddle 这里https://jsfiddle.net/vsdbL614/
添加回答
举报