How do you select elements in jQuery?

Selectors in jQuery are similar to CSS selectors.

  • $("#id") → Select element by ID
  • $(".class") → Select by class
  • $("p") → Select all <p> tags
  • $("p:first") → Select first <p>

Comments

Leave a Reply

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