- $
- ready
- find
- push
- index
- addClass
- hasClass
- removeClass
- toggleClass
- val
- prop
- html
- attr
- data
- text
- removeAttr
- css
- 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.
Parameters
selector
(string | HTMLElement)
Examples
$("*") // 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.
Parameters
handler
function
Examples
$(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
Parameters
selector
(string | HTMLElement)
Examples
$(".class").find(selector)
Returns any $
Get the index of the first element in the set of matched elements.
Parameters
element
(HTMLElement | $)
Examples
$(".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.
Examples
$(".class").index()
Returns number
Adds the specified class(es) to each element in the set of matched elements.
Parameters
className
string
Examples
$(".class").addClass(className)
Returns any $
Determine whether any of the matched elements are assigned the given class.
Parameters
className
string
Examples
$(".class").hasClass(className)
Returns boolean
Remove a single class or multiple classes from each element in the set of matched elements.
Parameters
className
string
Examples
$(".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.
Parameters
className
string
Examples
$(".class").toggleClass(className)
Returns $
Parameters
val
string
Examples
$(".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.
Parameters
prop
stringval
Examples
$(".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.
Parameters
html
string
Examples
$(".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.
Parameters
attr
stringval
Examples
$(".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.
Parameters
key
stringval
Examples
$(".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.
Parameters
text
string
Examples
$(".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.
Parameters
attr
string
Examples
$(".class").removeAttr(attr) // Remove an attribute from each element in the set of matched elements.
Parameters
Examples
$(".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.
Examples
$(".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}
Parameters
element
HTMLElement
Examples
$(".class").append(element) // Insert content, specified by the parameter, to the end of each element in the set of matched elements.
Returns $
Parameters
element
HTMLElement
Examples
$(".class").appendTo(element) // Insert every element in the set of matched elements to the end of the target.
Returns $
Parameters
element
HTMLElement
Examples
$(".class").after(element) // Insert content, specified by the parameter, after each element in the set of matched elements.
Returns $
Parameters
element
HTMLElement
Examples
$(".class").before(element) // Insert content, specified by the parameter, before each element in the set of matched elements.
Returns $
Parameters
element
HTMLElement
Examples
$(".class").prepend(element) // Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
Returns $
Examples
$(".class").clone() // Create a deep copy of the set of matched elements.
Returns HTMLElement
Examples
$(".class").empty() // Remove all child nodes and text content of the set of matched elements from the DOM.
Returns $
Examples
$(".class").remove() // Remove the set of matched elements from the DOM.
Returns $
Attach a handler to an event(s) for the elements.
Parameters
Examples
$(".class").on("click", handler)
Returns $
Remove an event(s) handler.
Parameters
Examples
$(".class").off("click")
Returns $
Remove an event(s) handler.
Parameters
Examples
$(".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.
Parameters
Examples
$(".class").one("click", handler)
Returns $
Execute all handlers and behaviors attached to the matched elements for the given event types.
Parameters
Examples
$(".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.
Parameters
Examples
$(".class").hover(onMouseOver, onMouseOut)
Returns $
Bind an event handler to the “submit” JavaScript event, or trigger that event on an element.
Parameters
handler
function
Examples
$(".class").submit(handler)
Returns $
Resets the values of all elements in the matched forms
Examples
$(".class").reset()
Returns $
Parameters
selector
(string | HTMLElement)
Examples
$(".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 $
Parameters
selector
(string | HTMLElement)
Examples
$(".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 $
Parameters
selector
(string | HTMLElement)
Examples
$(".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 $
Parameters
selector
(string | HTMLElement)
Examples
$(".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 $
Parameters
selector
(string | HTMLElement)
Examples
$(".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.
Examples
$(".class").serialize()
Returns string
Display the matched elements by fading them to opaque and visibility.
Parameters
time
number // animation time as milisecondscallback
function // callback function fired when animation is done
Examples
$(".class").fadeIn(time, callback)
Returns $
Hide the matched elements by fading them to opaque and visibility.
Parameters
time
number // animation time as milisecondscallback
function // callback function fired when animation is done
Examples
$(".class").fadeOut(time, callback)
Returns $
Show the matched elements by fading them to opaque and visibility.
Parameters
time
number // animation time as milisecondsdirection
string // "left" for left to right, "top" for top to bottom
Examples
$(".class").show(time, direction)
Returns $
Hide the matched elements by fading them to opaque and visibility.
Parameters
time
number // animation time as milisecondsdirection
string // "left" for left to right, "top" for top to bottom
Examples
$(".class").hide(time, direction)
Returns $
Toggle the matched elements by fading them to opaque and visibility.
Parameters
time
number // animation time as milisecondsdirection
string // "left" for left to right, "top" for top to bottom
Examples
$(".class").toggle(time, direction)
Returns $
An ajax request can be created by using following codes.
Parameters
options
object
Examples
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