본문 바로가기

Web/JQuery

Jquery empty() 실습

★ Sample Source

 

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("div").empty();
  });
});
</script>
</head>
<body>

<div style="height:100px;background-color:yellow">
This is some text
<p>This is a paragraph inside the div.</p>
</div>

<p>This is a paragraph outside the div.</p>

<button>Remove content of the div element</button>

</body>
</html>
 

 

화면 View 단

 

 

 

 

결과는 Remove content of the div element 를 클릭 할 경우 노란색 네모 안에 있는 text 글들이 모드 사라짐