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();
});
精彩评论