Created
November 28, 2011 15:24
-
-
Save mingomax/1400761 to your computer and use it in GitHub Desktop.
Teste se um Elemento HTML Existe com e sem Jquery
This file contains 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 */ | |
if( $('#id_do_elemento').length ) { | |
//Codigo | |
} | |
/* metodo tradicional sem JQuery */ | |
if(document.getElementById('id_do_elemento') != null) | |
{ | |
//Codigo | |
} | |
/* com o seletor do JQuery sempre nos retornará uma array de objetos tipados, logo a instrução length no auxilia nisto */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment