JQuery ternary operations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.