JQuery Selectors

please click here for more wordpress cource

JQuery selectors are used to select and manipulate HTML elements on a web page. Here are some commonly used jQuery selectors:

  1. Element Selector: Selects all elements with the specified tag name. For example, $(“p”) selects all <p> elements.
  2. ID Selector: Selects an element with a specified id attribute. For example, $(“#myId”) selects an element with id=”myId”.
  3. Class Selector: Selects all elements with a specified class attribute. For example, $(“.myClass”) selects all elements with class=”myClass”.
  4. Attribute Selector: Selects all elements that have the specified attribute, with a specified value. For example, $(“input[type=’text’]”) selects all <input> elements with type=”text”.
  5. Descendant Selector: Selects all elements that are descendants of a specified element. For example, $(“ul li”) selects all <li> elements that are descendants of <ul> elements.
  6. Child Selector: Selects all elements that are immediate children of a specified element. For example, $(“ul > li”) selects all <li> elements that are direct children of <ul> elements.
  7. Sibling Selector: Selects all elements that are siblings of a specified element. For example, $(“h1 + p”) selects all <p> elements that come immediately after <h1> elements.

These are just a few examples of the many jQuery selectors available. By using these selectors, you can easily manipulate and interact with elements on a web page.

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *