How to use # Selector Method in JQuery

This article describe about # Selector Method in JQuery.
  • 1523

Use (#) Selector method in jQuery

The # Selector method is choose id, and selects an HTML element.

We use only one id in a program, never be used another id.

In this program id is select <li> method to cover the color.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function ()

 {

        $("#choose").css("background-color", "yellow");

    });

</script>

</head>

<body>

<h1>This is JQuery</h1>

<p class="intro">Use # Selector</p>

<p>I am Aman</p>

<p>Hello World</p>

Who is your favorite:

<ul id="choose">

<li>My Self</li>

<li>My Friends</li>

</ul>

</body>

</html>

Output

op2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.