Skip to content

Instantly share code, notes, and snippets.

@katemalone
Last active August 26, 2019 17:27
Show Gist options
  • Save katemalone/f2e65745189bf38481ca699a6a10942d to your computer and use it in GitHub Desktop.
Save katemalone/f2e65745189bf38481ca699a6a10942d to your computer and use it in GitHub Desktop.

jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more.

How do you select HTML elements using element names, ID, or class? #id selector uses the id attribute of an HTML tag to find the specific element. $("#test")

.class selector finds elements with a specific class. $(".test") $(this) Selects the current HTML element.

Multiple Selectors Selects the combined results of all the specified selectors. jQuery( "selector1, selector2, selectorN" ) $( "div, span, p.myClass" ).css( "border", "3px solid red" );

checked Selector Matches all elements that are checked or selected. The :checked selector works for checkboxes, radio buttons, //and options of select elements.To retrieve only the selected options of select elements. $( "input" ).on( "click", function() { $( "#log" ).html( $( "input:checked" ).val() + " is checked!" ); });

When creating new elements (or selecting existing ones), jQuery returns the elements in a collection. Many developers new to jQuery assume that this collection is an array. It has a zero-indexed sequence of DOM elements, some familiar array functions, and a .length property, after all. Actually, the jQuery object is more complicated than that.

https://learn.jquery.com/using-jquery-core/jquery-object/ GO TO THIS SITE! https://learn.jquery.com/using-jquery-core/selecting-elements/ when searching type in jquery make sure you TYPE jQuery

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