属性选择器:

[attribute]
[attribute=value]// 属性等于  列入  $("input[value='male']").prop('chekced')  注意符号单引号双引号 判断单选框中 性别为男是否被选中  返回值为 false则为没有选中。
[attribute!=value]// 属性不等于

例子:

// 示例
<input type="text">
<input type="password">
<input type="checkbox">
$("input[type='checkbox']");// 取到checkbox类型的input标签
$("input[type!='text']");// 取到类型不是text的input标签

隔行变色例子:   

主要就是这一行:  $('tr:even').addClass('h2');   找到偶数行,添加class属性
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>各行变色</title>
    <style>
        .h2{background-color: red}
    </style>
</head>
<body>
<table border="3">
    <thead>
    <tr class="h1">
        <th>#</th>
        <th>姓名</th>
        <th>年龄</th>
    </tr>
    </thead>
    <tbody>
    <tr class="h1">
        <td>1</td>
        <td>egon</td>
        <td>ds</td>
    </tr>
    <tr class="h1">
        <td>2</td>
        <td>alex</td>
        <td>ss</td>
    </tr>
    <tr class="h1">
        <td>3</td>
        <td>jinxing</td>
        <td>ww</td>
    </tr>
    <tr class="h1">
        <td>4</td>
        <td>yuanhao</td>
        <td>cc</td>
    </tr>
    </tbody>
</table>
<script src="jquery-3.2.1.min.js"></script>
<script>
    // 行标签为tr 的行 隔行变色,找到偶数行,添加颜色属性,一句话搞定
    $('tr:even').addClass('h2');
</script>
</body>
</html>
View Code

相关文章:

  • 2021-10-17
  • 2021-09-26
  • 2022-01-26
  • 2021-06-14
  • 2021-11-12
猜你喜欢
  • 2021-06-05
  • 2021-05-25
  • 2021-07-24
  • 2022-01-11
  • 2021-07-19
  • 2021-07-17
相关资源
相似解决方案