>  기사  >  웹 프론트엔드  >  jQuery는 지정된 Class_jquery를 사용하여 요소를 삭제하기 위해 RemoveClass 메서드를 사용합니다.

jQuery는 지정된 Class_jquery를 사용하여 요소를 삭제하기 위해 RemoveClass 메서드를 사용합니다.

WBOY
WBOY원래의
2016-05-16 16:07:211211검색

이 기사의 예에서는 jQuery가 RemoveClass 메소드를 사용하여 지정된 클래스가 있는 요소를 삭제하는 방법을 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 구체적인 분석은 다음과 같습니다.

<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
 $("button").click(function(){
  $("h1,h2,p").removeClass("red");
 });
});
</script>
<style type="text/css">
.important
{
font-weight:bold;
font-size:xx-large;
}
.blue
{
color:blue;
}
</style>
</head>
<body>
<h1 class="red">Heading 1</h1>
<h2 class="red">Heading 2</h2>
<p class="red">This is a paragraph.</p>
<p>This is another paragraph.</p>
<br>
<button>Remove class from elements</button>
</body>
</html>

이 기사가 모든 사람의 jQuery 프로그래밍에 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.