- $
- Parameters
- Examples
- ready
- find
- push
- index
- addClass
- hasClass
- removeClass
- toggleClass
- val
- prop
- html
- attr
- data
- text
- removeAttr
- css
- height
- width
- innerHeight
- innerWidth
- outerHeight
- outerWidth
- offset
- append
- appendTo
- after
- before
- prepend
- clone
- empty
- remove
- on
- off
- unbind
- one
- trigger
- hover
- submit
- reset
- children
- parents
- siblings
- parent
- closest
- serialize
- fadeIn
- fadeOut
- show
- hide
- toggle
- ajax
Selects all elements with given selector.
selector
(string | HTMLElement)
$("*") // Select all elements in document
$(".class") // Selects all elements with the given class.
$("#id") // Selects a element with the given id.
$("[name=”value”]") // Selects elements that have the specified attribute with a value exactly equal to a certain value.
$("[name]") // Selects elements that have the specified attribute, with any value.
$(".class:eq(index)") // Select the element at index n within the matched set.
$(".class:gt(index)") // Select all elements at an index greater than index within the matched set.
$(".class:lt(index)") // Select all elements at an index less than index within the matched set.
$(".class:odd") // Selects odd elements, zero-indexed.
$(".class:even") // Selects even elements, zero-indexed.
This will also be an instance member, Observable#save.
handler
function
$(document).ready(function(){
...
})
Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. Selector can be use same as selectors
selector
(string | HTMLElement)
$(".class").find(selector)
Returns any $
Get the index of the first element in the set of matched elements.
element
(HTMLElement | $)
$(".class").push(element) // Add an element to the current set of matched elements.
$(".class").push($(".class")) // Add elements as Jquery ($) object to the current set of matched elements.
Returns $
Get the index of the first element in the set of matched elements.
$(".class").index()
Returns number
Adds the specified class(es) to each element in the set of matched elements.
className
string
$(".class").addClass(className)
Returns any $
Determine whether any of the matched elements are assigned the given class.
className
string
$(".class").hasClass(className)
Returns boolean
Remove a single class or multiple classes from each element in the set of matched elements.
className
string
$(".class").removeClass(className)
Returns $
Add or remove one or more classes from each element in the set of matched elements, depending on either the class’s presence or the value of the state argument.
className
string
$(".class").toggleClass(className)
Returns $
val
string
$(".class").val(val) // Set the given value of the all elements in the set of matched elements.
$(".class").val() // Get the current value of the first element in the set of matched elements.
Add or remove one or more classes from each element in the set of matched elements, depending on either the class’s presence or the value of the state argument.
prop
stringval
$(".class").prop(prop) // Get the value of a property for the first element in the set of matched elements.
$(".class").prop(prop, val) // Set a property for the set of matched elements.
html
string
$(".class").html(html) // Set the html contents of the all elements in the set of matched elements.
$(".class").html() // Get the html contents of the first element in the set of matched elements.
attr
stringval
$(".class").attr(attr, val) // Set the value of an attribute for the all elements in the set of matched elements.
$(".class").attr(attr) // Get the value of an attribute for the first element in the set of matched elements.
key
stringval
$(".class").data(key, val) // Store arbitrary data associated with the matched elements.
$(".class").data(attr) // Return arbitrary data associated with the first element in the jQuery collection, as set by data() or by an HTML5 data-* attribute.
$(".class").data() // Return all the data stores of the first element in the set of matched elements.
text
string
$(".class").text(text) // Set the text contents of the all elements in the set of matched elements.
$(".class").text() // Get the text contents of the first element in the set of matched elements.
attr
string
$(".class").removeAttr(attr) // Remove an attribute from each element in the set of matched elements.
$(".class").css(key, value) // Set the computed style properties for all elements in the set of matched elements.
$(".class").css(key) // Get the computed style properties for the first element in the set of matched elements.
$(".class").css({
propertyName1:propertyValue1,
propertyName2:propertyValue2
}) // Set the computed style properties for all elements in the set of matched elements.
Get the current computed height for the first element in the set of matched elements.
$(".class").height()
Returns number
Get the current computed width for the first element in the set of matched elements.
$(".class").width()
Returns number
Get the current computed height for the first element in the set of matched elements, including padding but not border.
$(".class").innerHeight()
Returns number
Get the current computed height for the first element in the set of matched elements, including padding but not border.
$(".class").innerWidth()
Returns number
Get the current computed outer height (including padding, border, and optionally margin) for the first element in the set of matched elements.
$(".class").outerHeight()
Returns number
Get the current computed outer width (including padding, border, and optionally margin) for the first element in the set of matched elements.
$(".class").outerWidth()
Returns number
$(".class").offset() // Get the current coordinates of the first element, or set the coordinates of every element, in the set of matched elements, relative to the document.
Returns object // {width: width, height: height, left: left, top: top}
element
HTMLElement
$(".class").append(element) // Insert content, specified by the parameter, to the end of each element in the set of matched elements.
Returns $
element
HTMLElement
$(".class").appendTo(element) // Insert every element in the set of matched elements to the end of the target.
Returns $
element
HTMLElement
$(".class").after(element) // Insert content, specified by the parameter, after each element in the set of matched elements.
Returns $
element
HTMLElement
$(".class").before(element) // Insert content, specified by the parameter, before each element in the set of matched elements.
Returns $
element
HTMLElement
$(".class").prepend(element) // Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
Returns $
$(".class").clone() // Create a deep copy of the set of matched elements.
Returns HTMLElement
$(".class").empty() // Remove all child nodes and text content of the set of matched elements from the DOM.
Returns $
$(".class").remove() // Remove the set of matched elements from the DOM.
Returns $
Attach a handler to an event(s) for the elements.
$(".class").on("click", handler)
Returns $
Remove an event(s) handler.
$(".class").off("click")
Returns $
Remove an event(s) handler.
$(".class").unbind("click", handler)
Returns $
Attach a handler to an event(s) for the elements. The handler is executed at most once per element per event type.
$(".class").one("click", handler)
Returns $
Execute all handlers and behaviors attached to the matched elements for the given event types.
$(".class").trigger("click", options)
Returns $
Bind one or two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
$(".class").hover(onMouseOver, onMouseOut)
Returns $
Bind an event handler to the “submit” JavaScript event, or trigger that event on an element.
handler
function
$(".class").submit(handler)
Returns $
Resets the values of all elements in the matched forms
$(".class").reset()
Returns $
selector
(string | HTMLElement)
$(".class").children(selector) // Get the children of each element filtered by given selector in the set of matched elements.
$(".class").children() // Get the children of each element in the set of matched elements.
Returns $
selector
(string | HTMLElement)
$(".class").parents(selector) // Get the ancestors of each element filtered by given selector in the current set of matched elements.
$(".class").parents() // Get the ancestors of each element in the current set of matched elements.
Returns $
selector
(string | HTMLElement)
$(".class").siblings(selector) // Get the siblings of each element filtered by given selector in the set of matched elements.
$(".class").siblings() // Get the siblings of each element in the set of matched elements.
Returns $
selector
(string | HTMLElement)
$(".class").parent(selector) // Get the parent of each element filtered by given selector in the current set of matched elements.
$(".class").parent() // Get the parent of each element in the current set of matched elements.
Returns $
selector
(string | HTMLElement)
$(".class").closest(selector) // For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
Returns $
Encode a set of form elements as a string for submission.
$(".class").serialize()
Returns string
Display the matched elements by fading them to opaque and visibility.
time
number // animation time as milisecondscallback
function // callback function fired when animation is done
$(".class").fadeIn(time, callback)
Returns $
Hide the matched elements by fading them to opaque and visibility.
time
number // animation time as milisecondscallback
function // callback function fired when animation is done
$(".class").fadeOut(time, callback)
Returns $
Show the matched elements by fading them to opaque and visibility.
time
number // animation time as milisecondsdirection
string // "left" for left to right, "top" for top to bottom
$(".class").show(time, direction)
Returns $
Hide the matched elements by fading them to opaque and visibility.
time
number // animation time as milisecondsdirection
string // "left" for left to right, "top" for top to bottom
$(".class").hide(time, direction)
Returns $
Toggle the matched elements by fading them to opaque and visibility.
time
number // animation time as milisecondsdirection
string // "left" for left to right, "top" for top to bottom
$(".class").toggle(time, direction)
Returns $
An ajax request can be created by using following codes.
options
object
example of options
{
url: URL,
type: 'POST', // POST or GET
processData: false,
contentType: false,
data: formData,
headers: { "X-CSRF-TOKEN": $('meta[name="_token"]').attr('content') },
success: function(response){
console.log(response);
},
error: function(error){
console.log(error);
}
}
example of options
{
url: URL,
type: 'POST', // POST or GET
processData: false,
contentType: false,
data: formData,
headers: { "X-CSRF-TOKEN": $('meta[name="_token"]').attr('content') },
}
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
$.ajax(time, options)
Returns Promise