Check if an input was loaded with jQuery

0

I need to check if an input text was loaded on the page and check if it is populated, how can I do that? I've tried $ ('input') on ('load') but it does not work, and the way the script is done I can not make a $ (document) .ready. Who knows a solution, please send it there

    
asked by anonymous 07.09.2016 / 20:48

1 answer

2

I think what you want to do is this:

Test by removing the value of value and then removing the input from the page!

As the test will be done on the page load, to do these tests. Copy the code and test on your machine!

var inputText = $('#teste').val();
if( inputText !== undefined) {
  
  if ( inputText != '' ) {
    alert('Foi carregado e está preenchido !');
  } else {
    alert('Foi carregado e não está preenchido!');  
  }
} else {
 alert('Não foi carregado!');      
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype="text" value="texto teste" id="teste" />
    
07.09.2016 / 23:43