jQuery Selector element

Introduction

The element selector selects all elements with the specific element name.

$("element")
Parameter Optional Description
element Required.the element to select

Select all <p> elements:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").css("background-color", "yellow");
});//from w w w. j  a  v a  2 s.  com
</script>
</head>
<body>

<h1>Welcome to My Homepage</h1>
<p class="intro">This is a test.</p>
<p>I am from java2s.com.</p>
<p>This is another test.</p>

Who is your favourite:
<ul id="choose">
  <li>Javascript</li>
  <li>HTML</li>
  <li>CSS</li>
</ul>

</body>
</html>



PreviousNext

Related