Home > Web Front-end > JS Tutorial > Detailed explanation of usage examples of element selector in jQuery

Detailed explanation of usage examples of element selector in jQuery

巴扎黑
Release: 2017-06-20 16:27:46
Original
1703 people have browsed it

This article mainly introduces the usage of element selector in jQuery. It analyzes the function, definition and related operation skills of element selector with examples. It has certain reference value. Friends in need can refer to it

The example in this article describes the usage of element selector in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This selector can match elements with the specified tag name. For example:

The code is as follows:

$("p")

The above code can select all p elements.
Grammar structure:

The code is as follows:

$(element)


Parameter list:

element. Points to the tag name of Example code:
Parameter Description
An element used to search DOM node.

The code is as follows:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<meta name="author" content="http://www.jb51.net/" />
<title>
元素选择器
-脚本之家</title>
<script type="text/
javascript
" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(
document
).ready(function(){
  $("span").css("color","green");
})
</script>
</head>
<body>
  <p>jQuery专区</p>
  <p>p+CSS专区</p>
  <p>JavaScript专区</p>
  <span>HTML专区</span>
</body>
</html>
Copy after login
The above code can put the span element in The font color is set to green.

The above is the detailed content of Detailed explanation of usage examples of element selector 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