Skip to content

Read: 02

Dayne edited this page Dec 3, 2019 · 2 revisions

JQuery abilities:

  • Find elements using CSS-style selectors
  • Do something with the elements using methods

Element context: .html() - selecting an HTML element.

.text() - specifically targeting (displayed) text.

.replacewith() - This method replaces every element in a matched set with new content. It also returns the replaced elements.

.remove() - This method removes all of the elements in the matched set.

.before() - This method inserts content before the selected element(s).

.after() - This method inserts content af ter t he selected element (s).

.prepend() - This method inserts content inside the selected element(s), after the opening tag.

.append() - This method inserts content inside the selected element(s), before the closing tag.

.attr() - This method can get or set a specified attribute and its value. To get the value of an attribute, you specify the name of the attribute in the parentheses.

.removeAttr() - This method removes a specified attribute (and its value). You just specify the name of the attribute that you want to remove from the element in the parentheses.

.addClass() - This method adds a new value to the existing value of the cl ass attribute. It does not overwrite existing values.

.removeClass() - This method removes a value from the cl ass attribute, leaving any other class names within that attribute intact.

.each() - Allows you to perform one or more statements on each of the items in the selection of elements that is returned by a selector - rather like a loop in JavaScript.

Clone this wiki locally