MDUI has a built-in lightweight JavaScript tool library. It has jQuery-like api and jQuery-style chain calls, but the volume is only one-sixth of jQuery.
You can pass mdui.JQ
To call the library, but it's better to put mdui.JQ
Stored in a short variable for easy recall. In order to avoid conflicts with other libraries, it is recommended to use $$
。
var $$ = mdui.JQ;
In the following documents, all use $$
To represent mdui.JQ
。
$$() |
There are multiple uses of this method: You can pass in a CSS selector as a parameter and return a JQ object containing the matched elements. This method is implemented by querySelectorAll.
You can pass in DOM elements, DOM element arrays, NodeList, JQ objects, and return JQ objects containing the specified elements.
You can pass in an HTML string and return a JQ object containing a DOM created from HTML.
You can pass in a function, which will be called after the DOM is loaded.
|
$$.extend() |
If only one object is passed in, the properties in the object will be merged into the JQ object, which is equivalent to adding new functions under the JQ namespace.
If two or more objects are passed in, the properties of all objects are added to the first object, and the merged object is returned.
|
$$.fn.extend() |
Extend methods on JQ's prototype chain.
|
$$.param() |
Serialize the array or object.
|
$$.each() |
Iterate over an array or object
|
$$.merge() |
Merge two arrays, the merged result will replace the contents of the first array, and return the merged result.
|
$$.unique() |
Delete duplicate elements in the array. It can be an array of DOM elements, an array of strings, and an array of numbers. Return the deduplicated array.
|
$$.map() |
Traverse the array or object, return a new array or object through the function,
|
$$.contains() |
Determine whether the parent node contains child nodes, and return a boolean value.
|
.is() |
Detect the set of matched elements based on CSS selectors, DOM elements, or JQ objects. If at least one element matches, return true, otherwise return false.
|
.length |
Returns the number of elements in the JQ object.
|
.each() |
Traverse a JQ object and execute a function for each matched element. If the function returns false, the traversal ends. The first parameter of the function is the index number of the element, and the second parameter is the current element. The this keyword of the function points to the current element.
|
.map() |
Traverse a JQ object, call a function for each element of the object, and generate a new JQ object that contains the return value of the function. The first parameter of the function is the index number of the element, and the second parameter is the current element. The this keyword of the function points to the current element.
|
.eq() |
Returns the JQ object of the element with the specified index number in the JQ object.
|
.first() |
Returns the JQ object of the first element in the JQ object.
|
.last() |
Returns the JQ object of the last element in the JQ object.
|
.get() |
Returns the DOM element with the specified index number in the JQ object. If no index number is specified, an array of all DOM elements in the JQ object will be returned.
|
.index() |
If no parameters are passed in, the index value of the first element in the JQ object relative to the sibling element is returned. If a CSS selector is passed in as a parameter, the index value of the first element in the JQ object relative to the element that matches the CSS selector is returned. If a DOM element is passed in, the index value of the DOM element in the JQ object is returned.
|
.slice() |
Returns a subset of JQ objects. The subset is the elements starting from start. If the end parameter is passed in, the elements from start to the position that do not contain end are extracted.
|
.filter() |
Filter out the JQ objects of the elements that match the specified expression from the JQ objects. Parameters can be CSS selectors, JQ objects, DOM elements, functions. When the parameter is a function, the first parameter of the function is the index number of the current element in the JQ object, the second parameter is the current element, and the this keyword points to the current element. When the function returns true, the element will be kept, when it returns false, the element will be removed.
|
.not() |
Filter out the JQ objects of the elements that do not match the specified expression from the JQ objects. Parameters can be CSS selectors, JQ objects, DOM elements, functions. When the parameter is a function, the first parameter of the function is the index number of the current element in the JQ object, the second parameter is the current element, and the this keyword points to the current element. When the function returns true, the element will be removed, when it returns false, the element will be retained.
|
.hasClass() |
Determine whether the first element in the JQ object contains the specified CSS class.
|
.addClass() |
Add CSS classes to the element. Multiple class names can be separated by spaces.
|
.removeClass() |
Remove the CSS class on the element. Multiple class names can be separated by spaces.
|
.toggleClass() |
If there are CSS classes on the element, delete them, and add them if they don’t. Multiple class names can be separated by spaces.
|
.prop() |
Gets or sets the attribute value of the selected element.
|
.removeProp() |
Delete the attribute value specified by the selected element.
|
.attr() |
Gets or sets the attribute value of the selected element.
|
.removeAttr() |
Delete the specified attribute value of the selected element.
|
.val() |
Gets or sets the value of the selected element.
|
.text() |
Gets or sets the text content of the selected element.
|
.html() |
Gets or sets the HTML content of the selected element.
|
$$.data() |
Read or store data on DOM elements.
|
$$.removeData() |
Delete the data stored on the DOM.
|
.data() |
Store data on the elements of the current JQ object.
|
.removeData() |
Delete the data stored on the elements of the JQ object.
|
.css() |
Get the style value of the first element in the JQ object, or set the style of each element.
|
.width() |
If no parameters are passed in, get the width of the first element in the JQ object. If a parameter is passed in, set the width of all elements in the JQ object. If the parameter is a number or a string of numbers, px will be automatically added as the unit. The value obtained by this method does not include the inner and outer margins by default. When box-sizing:border-box, the inner margin will be included.
|
.height() |
If no parameters are passed in, get the height of the first element in the JQ object. If a parameter is passed in, set the height of all elements in the JQ object. If the parameter is a number or a string of numbers, px will be automatically added as the unit. The value obtained by this method does not include the inner and outer margins by default. When box-sizing:border-box, the inner margin will be included.
|
.innerWidth() |
Get the width of the element, including the padding.
|
.innerHeight() |
Get the height of the element, including the padding.
|
.hide() |
Hide all elements in the JQ object.
|
.show() |
Restore the display state of all elements in the JQ object.
|
.toggle() |
Switch the display state of all elements in the JQ object.
|
.offset() |
Get the offset of the element relative to the document, as well as the width and height of the element.
|
.offsetParent() |
Returns the JQ object of the parent element of the first element in the JQ object for positioning. That is, the first element whose position is relative or absolute in the parent element.
|
.position() |
Get the offset of the element relative to the parent element, as well as the width and height.
|
.find() |
Find the specified set of descendant nodes according to the CSS selector.
|
.children() |
Get the direct child elements of the matched element, you can use the CSS selector as a parameter to filter. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.has() |
The child elements of the matched element are filtered according to the passed in parameters, and the JQ object of the filtered element is returned. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.parent() |
Returns the JQ object of the matched direct parent element. If no parameters are passed in, the JQ object of the direct parent element is returned directly. If a parameter is passed in, only the JQ object of the direct parent element that matches the parameter is returned. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.parents() |
Returns the JQ objects of all matched ancestor elements. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.parentsUntil() |
Find all the parent elements of the current element until the matching element is encountered. The returned JQ object contains all the parent elements found below, but does not contain the elements matched by the parameter.
|
.prev() |
Get the JQ object of the previous sibling element of the current element. You can use parameters for filtering. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.prevAll() |
Get the JQ objects of all sibling elements before the current element. You can use parameters for filtering. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.prevUntil() |
Get all the sibling elements in front of the current element, until a matching element is encountered, and no matching element is included. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.next() |
Get the JQ object of the next sibling element of the current element. You can use parameters for filtering. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.nextAll() |
Get the JQ objects of all sibling elements behind the current element. You can use parameters for filtering. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.nextUntil() |
Get all the sibling elements behind the current element, until a matching element is encountered, and the matching element is not included. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.closest() |
Matches from the current element upwards, and returns the first matched element. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.siblings() |
Get all sibling elements of the current element. You can use parameters for filtering. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.add() |
Add elements to the current JQ object. Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.empty() |
Remove all child nodes of the selected element from the DOM.
|
.remove() |
Remove all selected elements from the DOM.
|
.prepend() |
Insert the specified content in front of the selected element. The incoming parameters can be string, HTML, JQ object, DOM element, DOM element array, NodeList.
|
.prependTo() |
Add the selected element to the front of the inside of another specified element. Incoming Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.append() |
Insert the specified content behind the selected element. The incoming parameters can be string, HTML, JQ object, DOM element, DOM element array, NodeList.
|
.appendTo() |
Insert the selected element behind the inside of another specified element. Incoming Parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList.
|
.after() |
Insert content after the selected element. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList, HTML strings
|
.insertAfter() |
Insert the selected element after the specified element. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList, HTML strings
|
.before() |
Insert content before the selected element. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList, HTML strings
|
.insertBefore() |
Insert the selected element in front of the specified element. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList, HTML strings
|
.replaceWith() |
Replace the selected element with the new element. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList, HTML strings
|
.replaceAll() |
Replace the specified element with the selected element. The incoming parameters can be CSS selectors, JQ objects, DOM elements, DOM element arrays, NodeList
|
.clone() |
Copy all elements in the collection through deep cloning. Copy all the elements in the collection by deep cloning through the native cloneNode method. This method will not have data and event handlers copied to the new element. This is different from using a parameter in jquery to determine whether to copy data and event handling.
|
.serializeArray() |
Combine the values of the form elements into an array of key-value pairs of name and value.
|
.serialize() |
Serialize the form element array or object.
|
.on() |
Bind event handlers to specific events of each matched element.
|
.one() |
Bind event handlers to specific events of each matched element. But the event will only be triggered once. The usage of the method and |
.off() |
Unbound event from each matched element.
|
.trigger() |
Trigger the specified event
|
.ready() |
DOM Loaded,
|
$$.ajaxSetup() |
Set the global AJAX default parameters.
See the detailed parameter list below AJAX parameter。 |
$$.ajax() |
Send an AJAX request and return the XMLHttpRequest object it created.
See the detailed parameter list below AJAX parameter。 |
.ajaxStart() |
Global AJAX events. AJAX The function is executed at the beginning of the request.
|
.ajaxSuccess() |
Global AJAX events. AJAX The function is executed when the request is successful.
|
.ajaxError() |
Global AJAX events. AJAX The function is executed when an error occurs in the request.
|
.ajaxComplete() |
Global AJAX events. AJAX The function is executed when the request is completed.
|
parameter name | Parameter Type | Defaults | description |
---|---|---|---|
method |
String |
GET |
Request method. include:GET、POST、PUT、PATCH、HEAD、OPTIONS、DELETE |
data |
Object, String |
'' |
The data sent to the server. |
processData |
Boolean |
true |
Whether to convert the passed data into a query string and send it. |
async |
Boolean |
true |
Whether it is an asynchronous request. |
cache |
Boolean |
true |
Whether to read from the cache. Only right GET、HEAD The request is valid. |
username |
String |
'' |
HTTP User name for access authentication. |
password |
String |
'' |
HTTP Password for access authentication. |
headers |
Object |
{} |
add to Headers Data in. allowable beforeSend Rewrite this value in the callback function. |
xhrFields |
Object |
{} |
Set at XMLHttpRequest The data on the object.
|
statusCode |
Object |
{} |
HTTP An object composed of status codes and functions.
The status code between 200-299 indicates that the request is successful, the function parameters and |
dataType |
String |
text |
The type of data returned by the server. include:text、json、jsonp |
jsonp |
String |
callback |
JSONP The name of the callback function in the request. |
jsonpCallback |
String, Function |
Function to generate random string | JSONP The name of the requested callback function. You can specify a fixed name to enable the browser to cache GET request. |
contentType |
String |
application/x-www-form-urlencoded |
The encoding type of the content. for false Will not be set when Content-Type。 |
timeout |
Number |
0 |
The request timeout period (in milliseconds). When it is 0, it means never time out. |
global |
Boolean |
true |
Whether to trigger global AJAX events. |
beforeSend |
Function |
Called before the request is sent. return
|
|
success |
Function |
Called after the request is successful.
|
|
error |
Function |
Called when there is an error in the request.
|
|
complete |
Function |
Called after the request is completed.
|
.reflow() |
Redraw the current element.
|
.transition() |
Set the current element transition-duration Attributes.
|
.transitionEnd() |
Add a transitionend event callback on the current element.
|
.transform() |
Set the transform property of the current element.
|
.transformOrigin() |
Set the transform-origin property of the current element.
|
.mutation() |
Initialize the components of the current element and the components of child elements.
|
$$.showOverlay() |
Show the mask layer. You can pass in an integer parameter to indicate the z-index style of the mask layer, and the default is 2000.
|
$$.hideOverlay() |
Hide the mask layer. If you call $$.showOverlay() multiple times to show the mask layer, you also need to call $$.hideOverlay() the same number of times to hide the mask layer. You can force the mask layer to be hidden by passing in the parameter true.
|
$$.lockScreen() |
Lock the screen.
|
$$.unlockScreen() |
Unlock the screen. If you call $$.lockScreen() multiple times to display the mask layer, you also need to call $$.unlockScreen() the same number of times to hide the mask layer. You can force the mask layer to be hidden by passing in the parameter true.
|
$$.throttle() |
Function throttling. The first parameter is the function to be executed, and the second parameter is the delay time.
|
$$.guid() |
Generate a globally unique ID.
You can pass in a parameter. When the guid corresponding to the parameter value does not exist, a new guid will be generated and returned; when the guid corresponding to the parameter already exists, the existing guid will be returned directly.
|
Theme color
Main color
Accent color