jQuery USES the hide method to hide the class style usage instance of the specified element

  • 2020-05-19 04:12:43
  • OfStack

The example in this article shows how jQuery USES the hide method to hide the class style usage of the specified element. Share with you for your reference. The details are as follows:

The JS code below hides all elements whose class attributes are equal to test


<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
 $("button").click(function(){
  $(".test").hide();
 });
});
</script>
</head>
<body>
<h2 class="test">This is a heading</h2>
<p class="test">This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>

I hope this article is helpful for you to design jQuery program.


Related articles: