jQuery animate() max Height

Description

jQuery animate() max Height

View in separate window



<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from   w w w . j a  v  a  2s . co  m
<script>
$(document).ready(function(){
  $(".btn1").click(function(){
    $("#p1").animate({maxHeight: "+=100px"});
  });
  $(".btn2").click(function(){
    $("#p1").animate({maxHeight: "-=100px"});
  });
});
</script>
</head>
<body>

<button class="btn1">Animate +</button>
<button class="btn2">Animate -</button>

<p>This is a paragraph.</p>
<p id="p1" style="height:200px;">This is an animated paragraph.</p>
<p>This is a paragraph.</p>

</body>
</html>



PreviousNext

Related