Minifycode 2020-01-29 Viewed 1.3K times Jquery

In this article, you will learn how to use jQuery Method Chaining

 

The example chains together the css()slideUp(), and slideDown() methods. The p1 element first changes to red, then it slides up, and then it slides down:-

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("#p1").css("color", "green").slideUp(2000).slideDown(3000);
  });
});
</script>
</head>
<body>

<p id="p1">jQuery is fun!!</p>

<button>Click me</button>

</body>
</html>

jQuery Method Chaining
minify code