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

巴扎黑
巴扎黑Original
2017-06-20 16:27:461691browse

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>
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!

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