javascript - Deletion of class by js -


i display statements in html 2 depending on situation. these divas in bootstrap class: alert. page without overloading. therefore see old communication disappear after new data has been sent. how class div alert disappears.

function forgotusername() {     $('.panel-body').removeclass('alert');     var forgotusernamedto = {"email":$('#email').val()};     $.ajax({         type: 'put',         url: '/forgotusername',         contenttype: "application/json; charset=utf-8",         datatype: "json",         data: json.stringify(forgotusernamedto),         success: function (result) {             $('#forgotusernameform')                 .before('<div class="alert alert-dismissable alert-success">'                         + '<span th:text="#{forgotusername.success}">an e-mail has been sent. please allow few minutes inbox!</span>'                         + '</div>');         },         error: function (error) {             $('#forgotusernameform')                 .before('<div class="alert alert-dismissable alert-danger">'                         + '<span th:text="#{forgotusername.error}">no username found associated e-mail!</span>'                         + '</div>');         }     }); } 

you're doing

$('.panel-body').removeclass('alert'); 

the $.removeclass() function try remove class element, doesn't remove element. think want

$('.alert').remove();    //selects elements "alert" class, removes them page 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -