12312312
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title></Head><Body><Div> <Div> <inputtype= "button"onclick= "SelectAll ();"value= "Select All" /> <inputtype= "button"onclick= "Cancelall ();"value= "Cancel" /> <inputtype= "button"onclick= "Invertall ();"value= "Reverse Selection" /> </Div> <Div> <TableID= "Tab1"Border= "1px"> <thead> <TR> <th>Options</th> <th>IP Address</th> <th>Port</th> </TR> </thead> <tbody> <TR> <TD><inputtype= "checkbox" /></TD> <TD>1.1.1.1</TD> <TD>80</TD> </TR> <TR> <TD><inputtype= "checkbox" /></TD> <TD>1.1.1.2</TD> <TD>80</TD> </TR> <TR> <TD><inputtype= "checkbox" /></TD> <TD>1.1.1.3</TD> <TD>80</TD> </TR> <TR> <TD><inputtype= "checkbox" /></TD> <TD>1.1.1.4</TD> <TD>80</TD> </TR> <TR> <TD><inputtype= "checkbox" /></TD> <TD>1.1.1.5</TD> <TD>80</TD> </TR> <TR> <TD><inputtype= "checkbox" /></TD> <TD>1.1.1.6</TD> <TD>80</TD> </TR> </tbody> </Table></Div></Div><Scriptsrc= "Jquery-1.11.3.js"></Script><Script> functionSelectAll () {$ ('#tab1: CheckBox'). Prop ('checked',true); } functionCancelall () {$ ('#tab1: CheckBox'). Prop ('checked',false); } functionInvertall () {$ ('#tab1: CheckBox'). each (function () { //this.checked = this.checked? false:true; Ternary operation var v = condition? Positive values: False value //dom Mode /*if (this.checked) {this.checked = false; } else {this.checked = true; } */ //JQ Mode if($( This). Prop ('checked')){ $( This). Prop ('checked',false); } Else{ $( This). Prop ('checked',true); } }) }</Script></Body></HTML>
jquery check box Select all, Reverse, Cancel & ternary operations