Switch to full style
JQuery Examples
Post a reply

Remove HTML element or Delete its content

Mon Dec 31, 2012 10:05 pm

Remove HTML element or Delete its content
html code
<html>
<head>
<title>Remove & Empty</title>

<!--
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
 Note you can download the JQuery package instead of using Google version. --> 
<script src="jquery-1.8.3.js"></script>
<script>
$(document).ready(function(){
 // Remove HTML element 
  $("button#B1").click(function(){
    $("#part1").remove();
  });
  // Remove HTML content
    $("button#B2").click(function(){
    $("#part2").empty();
  });
  
   
 
  
});
</script>
</head>

<body>
<button id="B1">Remove</button>
<button id="B2">Empty</button>
 
<div id="part1" style="background:#0222F1;color:#F0F0F0;height:58px;width:300px;">
This html element will be removed after u click on Remove.</div>
<div id="part2"  style="background:#F22201;color:#F0F0F0;height:58px;width:300px;">
The content of this element will be remove once u click on Empty </div>
 
 
</body>
</html>




Post a reply
  Related Posts  to : Remove HTML element or Delete its content
 Change and get html content of element     -  
 How to delete/remove images from excel 2007 using POI.     -  
 Add and Remove CSS classes to html tag dynamically     -  
 opacity of HTML element- transparent     -  
 Get the position of HTML element using JQuery     -  
 How to make html element hidden using CSS     -  
 Get Width and Height -Inner and Outer for HTML element     -  
 removing focus border from a HTML element     -  
 checking if a HTML element is visible or hidden under JQuery     -  
 Show hint when focus on html element using JQuery     -  

Topic Tags

JQuery Content