javascript - error message hide using jquery -


here simple search box error message. error message should not appear on load. if input empty when button clicked, message should appear.

why in code error message appear on load though has kept hidden.

$( document ).ready(function() {     $('#error-msg').hide(); } 

fiddle: http://jsfiddle.net/karimkhan/xfdx7/

you not need jquery that. keep simple, add css in beginning:

 #error-msg{    display:none;  } 

and click button code:

$('.input-group-btn').click(function(){  if(!$('#url-input-box').val().length){   $('#error-msg').show();  }else{    $('#error-msg').hide();  } }); 

demo


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -