About properties
Javascript:
- GetAttribute
- SetAttribute
- RemoveAttribute
Jquery:
- attr (incoming property name): Gets the value of the property
- Attr (property name, property value): Sets the value of the property
- Attr (property name, function value): Sets the function value of the property
- attr (attributes): Sets multiple attribute values for the specified element: {attribute name one: attribute value one, property name two: ' Property value two ', ...}
About content
Javascript:
Jquery:
- . HTML () does not pass in a value, which is the HTML content that gets the first matching element in the collection
- . HTML (htmlstring) sets the HTML content of each matching element
- . HTML (function (index, oldhtml)) is used to return a function that sets HTML content
The. HTML () method is used internally by the DOM's innerHTML property to handle, so one of the most important issues to be aware of in terms of setup and acquisition is the entire HTML content (not just text content)
- . Text () Gets the merged text of each element in the matching element collection, including their descendants
- . Text (TextString) used to set the content of matching elements
- . text (function (index, text)) is used to return a function that sets the text content
The. Text () result returns a string containing the merged text for all matching elements
- The. Html method operation is the same as the. text, except that it is specific to the processing object
- . HTML handles the content of elements,. Text handles textual content
- . HTML can only be used in HTML documents, and. Text can be used in both XML and HTML documents
- If the object you are working with has only one child text node, the result of HTML processing is the same as text.
- Firefox does not support the InnerText property, using a similar textcontent property, the. Text () method combines support for 2 properties, so it can be compatible with all browsers
About values
Val () is used primarily for input, select, and textarea
- Val () No parameter, gets the current value of the first element in the matching element collection
- . val (value), sets the value of each element in the matching element collection
- . val (functions), a function to return the set value
Ps:
- The select element is processed through. Val (), and when no selection is selected, it returns null
- The. Val () method is used to set the value of the form's field
- If the select element has a multiple (multiple-selection) attribute, and at least one selection is selected, the. Val () method returns an array that contains the value of each selected selection
Summary of differences between. html (),. Text (), and. Val ():
- . HTML (),. Text (),. Val () Three methods are used to read the contents of the selected element; HTML () is used to read the elements of the HTML content (including HTML tags),. Text () is used to read the plain text content of the element, including its descendant elements,. Val () Is the "value" value that is used to read form elements. where the. html () and. Text () methods cannot be used on form elements, whereas. val () can only be used on form elements, and the. html () method only reads the first element when used on more than one element; the. val () method is the same as. html () If it is applied on more than one element. You can only read the value of the first FORM element (but Val can return multiple values if the Select is multi-select), but. Text () is not the same as they are, if. Text () is applied on more than one element, the textual content of all the selected elements is read.
- . HTML (htmlstring),. Text (TextString), and. Val (value) Three methods are used to replace the contents of the selected element, and if three methods are applied on more than one element at the same time, the contents of all the selected elements will be replaced.
- . HTML (),. Text (),. Val () can use the return value of the callback function to dynamically change the contents of multiple elements.
About class operations
AddClass Add Style
- . addclass (ClassName): One or more style names to add for each matching element
- . addclass (function (index, currentclass)): This function returns one or more style names to be added separated by spaces
Removeclass Delete a style
- . Removeclass ([ClassName]): One or more space-delimited style names removed by each matching element
- . Removeclass (Function (Index, Class)): A function that returns one or more style names that will be removed
Toggleclass Toggle Style
- . Toggleclass (ClassName): one or more (separated by spaces) style class names that are used to toggle on each element in the matching element collection
- . Toggleclass (className, switch): A Boolean value that determines whether a style should be added or removed
- . Toggleclass ([switch]): A Boolean value that is used to determine whether a style class is added or removed
- . Toggleclass (Function (Index, class, switch) [, switch]): A function that returns the name of the style class used to toggle on each element in the matching element collection. Receives the index position of the element and the element's old style class as a parameter
About Styles
Get:
- . CSS (PropertyName): Gets the computed value of the style property of the first element in the matching element collection
- . CSS (propertynames): Passing a set of arrays, returning an object result
Set up:
- . CSS (propertyname, value): Set CSS
- . CSS (propertyname, function): You can pass in a callback function and return to the corresponding value for processing
- . CSS (properties): You can pass an object and set multiple styles at the same time
About storage
Common methods of jquery