Home  >  jQuery

Example of .detach() in jQuery

May 01, 2013
.detach() in Jquery is called on any event. .detach() detaches the element from HTML Document and that element disappears. Synatx is
.detach()
 
Sample example is given below.

<!DOCTYPE html>
<html>
<head>
<style>p { background:yellow; margin:6px 0; } </style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<p>This is jQuery page.</p>
<button id="detach">Detach paragraphs</button>
<script>
var p;
$("#detach").click(function(){
 $("p").detach();
});

</script>
</body>
</html>
 

Output
FIND MORE TUTORILAS


©2019 concretepage.com | Privacy Policy | Contact Us