Home > Web Front-end > JS Tutorial > body text

How to hide a certain row in jquery

WBOY
Release: 2021-12-13 11:44:21
Original
2182 people have browsed it

jquery隐藏某一行的方法:1、利用eq()方法获取指定行元素对象,语法为“元素对象.eq(行元素的索引)”;2、利用hide()方法将获取到的指定行元素对象隐藏起来,语法为“行元素对象.hide(speed,callback)”。

How to hide a certain row in jquery

本教程操作环境:windows10系统、jquery3.2.1版本、Dell G3电脑。

jquery怎样隐藏某一行

jquery中,想要隐藏某一行,需要通过hide()方法,如果被选的元素已被显示,则隐藏该元素。

语法为:

$(selector).hide(speed,callback)
Copy after login

其中:

How to hide a certain row in jquery

示例如下:

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $(".btn1").click(function(){
  $("tr").eq(1).hide();
  });
});
</script>
</head>
<body>
<table border="1">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>
<button class="btn1">Hide</button>
</body>
</html>
Copy after login

输出结果:

How to hide a certain row in jquery

点击按钮之后:

How to hide a certain row in jquery

相关视频教程推荐:jQuery视频教程

The above is the detailed content of How to hide a certain row in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!