jQuery detect if textarea is empty

前端 未结 11 852
抹茶落季
抹茶落季 2020-12-25 11:05

I am trying to determine if a textarea is empty if a user deletes what is already pre-populated in the textarea using jQuery.

Anyway to do this?

This is what

11条回答
  •  隐瞒了意图╮
    2020-12-25 11:38

    You can simply try this and it should work in most cases, feel free to correct me if I am wrong :

    function hereLies(obj) { 
      if(obj.val() != "") { 
        //Do this here 
      }
    }
    

    Where obj is the object of your textarea.

    
    
    
    
    
    

    Value is not null!

提交回复
热议问题