2010-11-14 7 views
1

Si un champ est vide quand il est flou (perd le focus) Je veux supprimer une image:vérifier si un champ est vide dans jquery (js)?

Voici le code commençant:

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

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

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

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

Répondre

4
$("#type").blur(function() { 
    if (this.value === '') { 
    $('#image').hide(); 
    } 
}); 
+1

hourras cela fonctionne – getaway

+0

vous pourriez accepter la réponse alors :) – galambalazs

Questions connexes