2013-10-30 91 views
0

我在下面的代碼,它顯示resp,但如果我從輸入中刪除值。當輸入被刪除時,我有辦法清除課程嗎?如果更改清除div

代碼:

{ 
    if (resp == '') {  } 
    else { 
     $(".error").text(resp); 
    } 
}, 
error: function (resp) { 
    console.log(data); 
} 

調用:

$(document).ready(function() { 
    $('.postForm').on('blur', '#post_title', function (e) { 

     $(".postForm #post_url_link").blur(); 
    }); 

    function postTitleCheck() { 
     $(".postForm #post_title").blur(); 
    } 
}); 
+0

以清除利用.empty(),用於例如方法。 $(「。error」)。empty() –

+0

@SohilDesai雖然 –

+0

這段代碼是如何調用的 –

回答

1
if(!resp) 
    { 
    $(".error").text('');// here set blank if no response 

    }else{ 
     $(".error").text(resp);// here set response if it comes 
    } 
0
$(".error").empty(); 

if(resp != '') 
    $(".error").text(resp);