Skip to content

Instantly share code, notes, and snippets.

@azat-co
Last active November 2, 2022 19:33
Show Gist options
  • Save azat-co/5898111 to your computer and use it in GitHub Desktop.
Save azat-co/5898111 to your computer and use it in GitHub Desktop.
The list of most commonly used jQuery API functions

Here is the list of most commonly used jQuery API functions:

  • find(): Selects elements based on the provided selector string
  • hide(): Hides an element if it was visible
  • show(): Shows an element if it was hidden
  • html(): Gets or sets an inner HTML of an element
  • append() Injects an element into the DOM after the selected element
  • prepend() Injects an element into the DOM before the selected element
  • on(): Attaches an event listener to an element
  • off() Detaches an event listener from an element
  • css(): Gets or sets the style attribute value of an element
  • attr() Gets or sets any attribute of an element
  • val(): Gets or sets the value attribute of an element
  • text(): Gets the combined text of an element and its children
  • each(): Iterates over a set of matched elements
@rolandin
Copy link

rolandin commented Mar 26, 2017

Sounds about right.
Please if some one has favorites used methods like CraigglesO with animate(), please share.
Might help others, I've been using animate.css framework for animations, I'm gonna dig a little bit more into animate() to see what kind of things I can reach.. although, is not better do the animations with CSS as long as we could be able to do them ??

@tejas-kr
Copy link

hey .toggle() is used more frequently than .hide() and .show()

@bonucci
Copy link

bonucci commented Sep 6, 2017

.toggleClass()

@alex0121
Copy link

offset(), scrollTop() and resize() are good too especially when you want to make a position fixed element responsive when it is not set to top: 0 or left: 0

@rakin92
Copy link

rakin92 commented Nov 22, 2017

how come .toggle() not included!

@ChrisHPZ
Copy link

Agreed about .css I find I use it all the time, especially if I have to inject some height dimensions into a child div. outerWidth and outerHeight are another couple functions I use all the time.

@gtwade
Copy link

gtwade commented Apr 9, 2018

This is probably a list that's relevant to the author more than a statement of what's truly essential jquery. Your own personal list will no doubt be different.

@BerinH
Copy link

BerinH commented May 21, 2018

append appends inside the selected element in the last position.
Ditto for prepend, only at the start. Useful list though :-).

@k3kenan
Copy link

k3kenan commented Mar 22, 2019

Maybe you want to check out this:
tesodev/jqueryLite

@GReaper-DEV
Copy link

// Gets or Sets the value of the attribute. e.x $("input[type='checkbox'].prop("checked"); It returns false or true. To set a value: $("input[type='checkbox'].prop("checked", false);
.prop()

Also,
is();

//It's similar to .prop(), but only get's the value, true or false of an attribute in an element. e.x $("input[type='checkbox'].is(":checked");
A semicolon must be inserted too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment