jQuery animate() max Width

Description

jQuery animate() max Width

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 ww w . j av  a 2  s. c o  m*/
<script>
$(document).ready(function(){
  $(".btn1").click(function(){
    $("#p1").animate({maxWidth: "+=50px"});
  });
  $(".btn2").click(function(){
    $("#p1").animate({maxWidth: "-=50px"});
  });
});
</script>
</head>
<body>

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

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

</body>
</html>



PreviousNext

Related