Select a page element, and then do something about it
$ (document)//Select Entire Documents Object
$ (' #myId ')//select page element with ID myId
$ (' div.myclass ')//select div element with class MyClass
$ (' input[name=first] ')//Select the name attribute equals first INPUT element
$ (' A:first ')//Select First a element in Web page
$ (' tr:odd ')//select odd rows of the table
$ (' #myForm: Input ')//Select INPUT element from form
$ (' div:visible ')//select the visible div element
$ (' Div:gt (2) ')//Select all DIV elements except the first three
$ (' div:animated ')//Select a DIV element that is currently in the animated state
$ (' div '). has (' P '); Select the div element that contains the P element
$ (' div '). Not ('. MyClass '); Select a DIV element that is not equal to the MyClass class
$ (' div '). Filter ('. MyClass '); Select a DIV element with class equal to MyClass
$ (' div '). First (); Select a 1th div element
$ (' div '). EQ (5); Select a 6th div element
$ (' div '). Next (' P '); Select the first P element after a DIV element
$ (' div '). parent (); Select the parent element of the DIV element
$ (' div '). Closest (' form '); Select the form parent element closest to Div
$ (' div '). Children (); Select all child elements of Div
$ (' div '). siblings (); Select sibling elements of Div
$ (' div '). Find (' H3 '). EQ (2). html (' Hello ');
$ (' div ')//Find DIV element
. Find (' H3 ')//Select one of the H3 elements
. EQ (2)//Select a 3rd h3 element
. html (' Hello '); Change its contents to Hello
$ (' H1 '). html (); HTML () has no parameters, which means that the value of H1 is removed
$ (' H1 '). html (' Hello '); HTML () has parameter Hello, which means to assign a value to the H1
. HTML () to remove or set HTML content
. Text () to remove or set text content
. attr () to remove or set the value of a property
. width () to remove or set the width of an element
. Height () to remove or set the height of an element
. Val () takes out the value of a FORM element
. InsertAfter () and. After (): Inserts an element from behind an existing element
. InsertBefore () and. Before (): Outside the existing element, insert the element from the front
. AppendTo () and. Append (): Inserts an element from behind within an existing element
. Prependto () and. Prepend (): Inside the existing element, insert the element from the front
The basic design idea and main usage of jquery