1. Manipulate any attribute
A, attr ()
// 1. Read the Title property of the first Div console.log ($ ( " div: First "). attr ( ' title " ) // one // 2. Set the Name property for all Div (value is Atguigu) $ ( " div " ). attr ( ' name , " tom )
B, Removeattr ()
// 3. Remove the title attribute of all Div $ ('div'). Removeattr ('title ' )
C, prop
//11. Click the ' Select All ' button to select all//attr (): Action property value is not a Boolean value property//prop (): A property that specializes in manipulating property values to Boolean values var$checkboxs = $ (': CheckBox') $('Button:first'). Click (function () {$checkboxs. Prop ('checked',true) }) //12. Click the ' Select All ' button to make all the selections$('Button:last'). Click (function () {$checkboxs. Prop ('checked',false) })
2. Operation Class Property
A, addclass ()
// 4. Give all div settings class= ' name ' $ ( " div Span style= "COLOR: #800000" > ). attr ( " Class ", " Name " ) 5. Add class= ' abc ' $ ( " to all Div Span style= "COLOR: #800000" >div "). AddClass ( " ABC )
B, Removeclass ()
3. Manipulate HTML code, text, value
A, HTML ()
// 7. Get the last Li tag body text console.log ($ ('li:last'). HTML ()) // 8. Set the first Li's label body as " $ ('li:first' ). html ('')
B, Val ()
// 9. Get the value in the input box console.log ($ (': Text'// read 10. Set the value of the input box to Atguigu $ (': Text'). Val (' Value'// set read-write Unity
JQuery (Property manipulation)