This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input.checked = input.checked ^ 1; | |
input.checked = true ^ 1; //converte implicitamente true para 1; false para 0 | |
input.checked = 1 ^ 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('input')[0].checked ^= 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = $('input')[0]; | |
input.checked = input.checked ^ 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input.checked = 1 ^ 1; //1 e 1 são iguais (não me diga?) | |
input.checked = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input.checked = 0; | |
input.checked = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 ^ 1 === 0 //checkada (1) é == 1 então retorna 0 | |
0 ^ 1 === 1 //não checkada (0) é != 1 então retorna 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> +'' | |
<<< 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> [1, 2].toString() | |
<<< "1,2" | |
>>> [1, 2] == '1,2' | |
<<< true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#IDinexistente').css('backgroundColor', 'green'); | |
document.getElementById('IDinexistente').style.backgroundColor = 'green'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//com jQuery | |
$('#talvezExista').css('backgroundColor', 'green'); | |
//JS nativo | |
var el = document.getElementById('talvezExista'); | |
if (el) { | |
el.style.backgroundColor = 'green'; | |
} |