• jQuery Remove Elements

    jQuery Remove Elements

    With jQuery, it is easy to remove existing HTML elements. To remove elements and content, there are mainly two jQuery methods:

    1. remove() – Removes the selected element (and its child elements)
    2. empty() – Removes the child elements from the selected element

    remove() method:

    The jQuery remove() method removes the selected element(s) and its chile elements.

    Example:

    $(“#div1”).remove();

    The jQuery remove() method also accepts one parameter, which allows you to filter the elements to be removed. The parameter can be any of the jQuery selector syntaxes.

    Example:

    The following example removes all <p> elements with class=”italic”.

    $(“p”).remove(“.italic”);

    empty() method:

    The jQuery empty() method removes the all child elements of the selected element(s).

    Example:

    $(“div1”).empty();

    Appreciate my work :Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on PinterestShare on RedditShare on StumbleUponShare on TumblrDigg thisShare on YummlyShare on VKFlattr the authorBuffer this page

Leave a Reply

Your email address will not be published. Required fields are marked *