Home >Web Front-end >JS Tutorial >jquery basic selector

jquery basic selector

无忌哥哥
无忌哥哥Original
2018-06-29 11:04:351274browse

jquery basic selector

1. The selectors in jquery are basically the same as those in css, making it easy for developers who are familiar with css to quickly master

2. Most Most css selectors can be used directly in jquery

3. Basic selectors, also called basic selectors, or entry selectors, are simple selectors whose function is to provide jquery with

Elements are used for subsequent filters to operate. There are four main categories: tag, id, class, *

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>基本选择器</title>
<style type="text/css">
table, td {
border:1px solid #333;
}
table {
border-collapse: collapse;
margin: 30px auto;
width: 80%;
text-align: center;
}
table caption {
font-size: 1.5em;
margin-bottom: 15px;
}
.bg-orange {
font-weight: bolder;
color: white;
background-color: orange;
}
</style>
</head>
<body>
<table>
<caption>用户信息表</caption>
<tr id="title">
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>10</td>
</tr>
</table>
</body>
</html>
<script type="text/javascript" src="../js/jquery-3.3.1.js"></script>
<script type="text/javascript">
//1. tag标签选择器
// $(&#39;td&#39;).css(&#39;backgroundColor&#39;,&#39;wheat&#39;)
//2.id选择器
//把td上的背景去掉,否则会层叠覆盖
$(&#39;#title&#39;).css(&#39;backgroundColor&#39;,&#39;lightgreen&#39;)
//3.class类选择器
$(&#39;.mark&#39;).addClass(&#39;bg-orange&#39;)
//4.*通配选择符
$(&#39;tr:nth-child(3) ~ *&#39;).css(&#39;backgroundColor&#39;, &#39;pink&#39;)
</script>

The above is the detailed content of jquery basic selector. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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