Post

jQueryjQuery

n
naveen nani

Posted on 28th February 2024|20 views

0
votes

Jquery Selector Attribute

What is jQuery [attribute=value] Selector?

Answers
P
ravi sankar

Posted on 28th February 2024

The [attribute = value] selector, selects every element with the particular attribute and value.

Syntax:

$(“[attribute=value]”)

Example:

<!DOCTYPE html>

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("[id=choose]").css("background-color", "red");

});

</script>

</head>

<body>

<h1>Welcome</h1>

<p class="intro">My name is Schinchan.</p>

<p>I live in Kasukabe.</p>

<p>My best friend is Masaw.</p>

Who is your favourite:

<ul id="choose">

  <li>Hiroshi</li>

  <li>Actionkamen</li>

  <li>Mitsi</li>

</ul>

</body>

</html>

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos