Home html Remove html div content

Remove html div content

Author

Date

Category

There is a div, I insert the data that comes from the ajax request into it:

function onAjaxSuccess (data)
    {
       $ ("# divShow"). append (data);
    }

Need a function to clear the div content, tried it like this:

function DeletePrice ()
    {
      $ ("# divShow"). remove ();
    }

The content is deleted, but now data insertion is possible only after refreshing the page, as I understand it, DeletePrice deletes the block itself, not its content.

Question: how to remove content div?


Answer 1, authority 100%

To remove all children of an element in jQuery there is empty method .

$ ('# divShow'). empty ();

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions