Curtis Crewe
Curtis Crewe

Reputation: 4336

jQuery remove() retrieval

Basically i'm using an OnClick call to remove a DIV, once i click the OnClick it calls the remove() jQuery function to delete a div,

here's my current code for the div that it removes using remove().

<div id="add">
<button type="submit" onclick="showdiv('adduser');">Add User</button>
</div>

The javascript call for "showdiv" is

function showdiv(id){
    $("#add").remove();
    document.getElementById(id).style.display = "inherit";
}

Inside the div id "adduser" i want to show another button to do an onclick to bring back div id "add", is that possible and what's the best way to do it ?

Upvotes: 1

Views: 56

Answers (1)

Adil
Adil

Reputation: 148180

You can use show() and hide() functions instead of removing the div permanently using remove()

function showdiv(id){
    $("#add").hide();
    document.getElementById(id).style.display = "inherit";
}

Upvotes: 2

Related Questions