element Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:element

Description

The element selector selects elements by element name.

Syntax

Parameter Description
element Required. element name to select

The following code shows how to select all <p> elements:

Demo Code

ResultView the demo in separate window

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

<h1>Welcome to My Homepage</h1>
<p class="intro">This is a test.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>

Who is your favourite:
<ul id="choose">
  <li>A<p>This is a paragraph.</p></li>
  <li>B</li>
  <li>C<p>This is a paragraph.</p></li>
</ul>

</body>
</html>

Related Tutorials