jquery ternary operation Syntax:
var value = condition? value1:value2;
Explanation: Set a variable value, judge according to the condition, if the condition is true, set value=value1, otherwise value=value2
Instance:
<script src= "Js/jquery-3.1.1.js" ></script><script type= "Text/javascript" >function CheckAll () {$ ( ': CheckBox '). Prop (' checked ', true);} function Cancleall () {$ (': CheckBox '). Prop (' checked ', false);} </script><script type= "Text/javascript" >function Reverseall () {$ (': CheckBox '). each (function () {//if ( this.checked) {//this.checked = false;//}else{//this.checked = true;//}//if ($ (this). Prop (' checked ')} {//$ (this). Prop (' checked ', false);//}else{//$ (this). Prop (' checked ', true);//}var v = $ (this). Prop (' checked ')? false:true;$ (This). Prop (' checked ', v);})} </script>
Prop Properties:
$ (this). Prop (' checked '): Represents the value that gets the Checked property,
$ (this). Prop (' checked ', True/false): Indicates that the value of the set checked property is True/false.
Prop common language checked and selected properties
This: Represents a DOM object, $ (this) represents a jquery object, and only jquery objects can use the jquery method.
This article is from the "Zengestudy" blog, make sure to keep this source http://zengestudy.blog.51cto.com/1702365/1921115
JQuery ternary operations