开发者

jquery empty text box event

开发者 https://www.devze.com 2023-02-15 12:31 出处:网络
I can make a div hide when a textbox is in use like this: 开发者_StackOverflow$(\"#text-box\").**keyup**(function(){

I can make a div hide when a textbox is in use like this:

开发者_StackOverflow  $("#text-box").**keyup**(function(){
    $("#container").hide();
  });

....but how do I show the div again when the text box is empty:

 $("#text-box").**what-event-goes-here??**(function(){
    $("#container").show();
  });


EDIT: the correct event is 'keyup'

$("#text-box").bind("keyup", function() { 
   if ($(this).val() == "")
     $("#container").show();
});


if container is by default hidden then u can also use below code

$("#text-box").bind("keyup", function() { 
   if ($(this).val() =='')
     $("#container").show();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号