CodeIgniter Forums
Switch var from TRUE to FALSE (jQuery) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Switch var from TRUE to FALSE (jQuery) (/showthread.php?tid=29276)



Switch var from TRUE to FALSE (jQuery) - El Forum - 04-04-2010

[eluser]Fielder[/eluser]
If I have a jquery variable as such, how can I easily flip it.
Code:
var print = true;
I want to change the value of var print to false, without having to do if/else statement.
Code:
if (print == true)
{
    print = false;
}
else
{
    print = true;
}
Or what would be the shorthand if/else statement for it? Just looking for cleaner code for such a simple function.


Switch var from TRUE to FALSE (jQuery) - El Forum - 04-04-2010

[eluser]BilliamTheSecond[/eluser]
print = !print;