removeClass(class) trong jQuery



Miêu tả

Phương thức removeClass(class) trong jQuery gỡ bỏ tất cả hoặc các lớp đã cho từ tập hợp các phần tử được so khớp

Cú pháp

Sau đây là cú pháp cho removeClass(class) trong jQuery:

selector.removeClass( class )

Tham số

Dưới đây miêu tả chi tiết về các tham số được sử dụng trong phương thức removeClass(class) trong jQuery:

  • class − Tên của lớp CSS.

Quảng cáo

Ví dụ

Sau đây là ví dụ đơn giản minh họa cách sử dụng của phương thức removeClass(class) trong jQuery. Ví dụ này sẽ gỡ bỏ class là red từ đoạn văn đầu tiên.

<html>
   <head>
      <title>The Selecter Example</title>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
   
      <script type="text/javascript" language="javascript">
         $(document).ready(function() {
            $("p#pid1").removeClass("red");
         });
      </script>
		
      <style>
         .red { color:red; }
         .green { color:green; }
      </style>

   </head>
	
   <body>
      <p class="red" id="pid1">This is first paragraph.</p>
      <p class="green" id="pid2">This is second paragraph.</p>
   </body>
	
</html>

Nó sẽ cho kết quả:

Các bài học jQuery khác tại VietJack:


thuoc_tinh_trong_jquery.jsp