Jess McKenzie
Jess McKenzie

Reputation: 8385

Clearing a div if changed

I have the following code below and it shows the resp but if I delete the value from the input. Is there a way that I can clear the class when the input is deleted?

Code:

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

Invoke:

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

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

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

Upvotes: 0

Views: 46

Answers (2)

Sohil Desai
Sohil Desai

Reputation: 2988

$(".error").empty();

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

Upvotes: 0

Rituraj ratan
Rituraj ratan

Reputation: 10378

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

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

Upvotes: 1

Related Questions