Properties
1. Properties
1.1 attr (NAME|PROPERTIES|KEY,VALUE|KEY,FN)
1) Get the property value $ ("img"). attr ("src");
2) Set the property value $ ("img"). attr ("title", "Hello"); $ ("img"). attr ({src: "img1.png", alt: "IMG1"})
3) Set the property value $ ("img"). attr ("Alt", function (index,value) {return value + index})//index is the index of the current element, and value is the original property value of "Alt"
1.2 Removeattr (name)
Delete an attribute $ ("img"). REMOVEATTR ("alt");
1.3 Prop (NAME|PROPERTIES|KEY,VALUE|KEY,FN)
$ ("input[type= ' checkbox ']"). Prop ("checked", true);
$ ("input[type= ' checkbox ']"). Prop ("Checked", function (I, Val) {return!val; });
1.4 Removeprop (name)
Used to delete a property set set by the. Prop () method
The difference between 1.5 attr () and prop ()
Properties with True and false two properties, such as checked, selected or disabled use Prop (), others using attr ()
2.css class
2.1 AddClass (CLASS|FN)
$ ("P"). ADDCLASSS ("active focus");
$ ("ul Li"). addclass (function (i,class) {return class+i})
2.2 Removeclass ([NAME|FN])
$ ("P"). Removeclass ("active");
$ ("P"). Removeclass (function () {return $ (this). attr ("Class")})
2.3 Toggleclass (CLASS|FN)
$ ("P"). Toggleclass ("active");
$ (". Class"). Toggleclass (function () {
if ($ (this). Parent (). is (". MyClass"))
{
return "Classone";
}
Else
{
return "Classtwo";
}
})
3.HTML Code | text | value
3.1 HTML ([VAL|FN])
Gets the content $ ("div"). html () Get the HTML content of the first matching element
Set content $ ("div"). html ("<p><span>htmlhtmlhtml</span></p>");
$ ("div"). html (function (index,html) {return html+index})
3.2 Text ([VAL|FN])
Gets the content $ ("P"). Text ()
Set content $ ("P"). Text ("Texttexttext")
$ ("P"). Text (function (index,text) {return index+text})
3.3 Val ([Val|fn|arr])
Gets the value $ ("input"). Val ();
Set the value $ ("input"). Val ("2222222");
$ ("input"). Val (function (index,value) {return index + value})
Value//array operation for Check/select
$ ("input"). Val (["Check2", "Radio1"]);
CSS
1.css
1.1 css (NAME|PRO|[,VAL|FN])
Gets the Style property value $ ("P"). CSS ("color")
Set Style property value $ ("P"). CSS ("Color", "red")
$ ("P"). CSS ({color: "Red", Width: "100px"})
$ ("P"). CSS ({
Width:function (index,value) {return parsefloat (value) * 1.2;},
Height:function (index,value) {return parsefloat (value) * 1.2;}
})
1.2 Jquery.csshooks
2. Location
2.1 offset ([coordinates]) gets the relative offset of the matched element at the current viewport
Gets the offset value $ ("P"). Offset ()
Set offset Value $ ("P"). Offset ({top:100,left:100})
$ ("P"). Offset (function (i,c) {//c) represents the current coordinates of the selector
Newpos=new Object ();
newpos.left=c.left+100;
newpos.top=c.top+100;
return newspos;
})
2.2 Position () Gets the offset of the matching element relative to the parent element.
$ ("P"). Position ()
2.3 ScrollTop ([Val]) Gets the offset of the top of the matching element relative to the scroll bar.
Gets the $ ("P"). ScrollTop ()
Set the $ ("P"). ScrollTop (500)
2.4 ScrollTop ([Val]) Gets the offset of the top of the matching element relative to the scroll bar.
Gets the $ ("P"). ScrollLeft ()
Set the $ ("P"). ScrollLeft (500)
3. Dimensions
3.1 Height ([VAL|FN])
Gets the $ ("P"). Height ()
Set the $ ("P"). Height (500)
$ ("P"). Height (function (i,c) {return c+200;})
3.2 width ([VAL|FN])
Gets the $ ("P"). Width ()
Set the $ ("P"). Width (500)
$ ("P"). Width (function (i,c) {return c+200;})
3.3 Innerheight () gets the inner area height of the first matched element (including padding (padding), excluding borders).
$ ("P"). Innerheight ();
3.4 innerwidth () Gets the inner area width of the first matched element (including padding (padding), excluding borders).
$ ("P"). Innerwidth ();
3.5 outerheight ([options]) Gets the outer height of the first matching element (including padding and borders by default).
If the options value is true, the margin (margin) is calculated, and the default value is False
3.6 Outerwidth ([options]) Gets the outer width of the first matching element (including padding and borders by default).
If the options value is true, the margin (margin) is calculated, and the default value
JQuery properties and CSS actions