① relative positioning of jquery elements.
In jquery, you can not only use the selector to perform absolute positioning, but also perform relative positioning, if you specify the second parameter in $ (), the second parameter is the relative element. When the second parameter is passed to a jquery object, the parameter is selected relative to the object as the benchmark.
<HTML>
Run:
② $ ("Div [ID]") Select the DIV with the ID attribute
③ $ ("Div [ Title = test ] ") Select the DIV whose title attribute is" test. Note: An equal sign.
$ ("Div [Title ! = Test] ") Select a div whose title attribute is not" test"
④ $ ("Input: checked ") Note: There is no space between input and: checked.
⑤ Difference between $ ("input") and $ (": Input ")
$ ("Input") can only obtain the <input> label, but <textarea>, <SELECT>, and so on cannot be obtained.
$ (": Input") not only can get the <input> label, but can get the form from the submit server such as <textarea> and <SELECT>.
Similarly, you can use $ ("input [type = text]") to obtain all single-line text boxes. For example, $ (": passowrd"), $ (": Radio"), $ (": checkbox"), $ (": Submit"), and $ (": image "), $ (": reset "), $ (": button "), $ (": file "), $ (": hidden ")
⑥ Use the ATTR () method to read or set the attributes of an element, and use ATTR to operate encapsulation attributes not available in jquery.
$ ("# A: First"). ATTR ("href", "http://baidu.com ");
7. Delete the removeattr attribute. Source code Cannot see, the difference between this and clearing properties.
⑧ Dynamically create DOM nodes
Use $ (HTML string) to dynamically create a DOM node, return a jquery object, and call the append method to add the created node to the Dom.
VaR link = $ ("<a href = 'HTTP: // www.baidu.com '> Baidu </a> ");
$ ("Div: First"). append (Link );
The append method is used to append an element to the end of an element (add a child element to become the last child element)
The prepend method adds an element (add a child element to become the first child element) at the beginning of the element)
The After method adds an element after the element (add brother)
Before method adds an element before the element (add brother)
⑨ Delete a node
Remove () deletes the selected node. This method returns the deleted Node object and can continue to use the deleted node.
VaR list = $ ("# ulleft Li. test"). Remove ();
$ ("# Ulright"). append (list );
Prevent event bubblesE. stoppropagation ();
Block default behavior: E. preventdefault () and window. event. returnvalue = false have the same effect.