【问题标题】:checking if a field is empty in jquery(js)?检查jquery(js)中的字段是否为空?
【发布时间】:2010-11-14 18:48:48
【问题描述】:

如果字段模糊(失去焦点)时为空,我想删除图像:

这是开始的代码:

$('#type').keyup(function(){
   $('#image').show();

 $("#type").blur( function() {

// i wanted to check here if #type field is empty as well before hiding?

        $('#image').hide();
});

【问题讨论】:

    标签: jquery html css image input


    【解决方案1】:
    $("#type").blur( function() {
      if (this.value === '') {
        $('#image').hide();
      }
    });
    

    【讨论】:

      猜你喜欢
      • 2011-05-13
      • 2011-02-25
      • 1970-01-01
      • 1970-01-01
      • 2012-02-21
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多