开发者

jquery empty text box event

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜