Q:

Increase the size of a division when you click it using jquery

0

Increase the size of a division when you click it using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Increase the size of a div when you click it.</title>
</head>
<body>
<div class="div1">Click to increase the size</div>
<div class="div2">Click to increase the size</div>
</body>
</html>

CSS Code :

.div1 {
    width: 100px;
    height: 60px;
    background-color: #f33;
    color: white
  }
.div2 {
    width: 100px;
    height: 60px;
    background-color: #a14;
    color: white
  }

JavaScript Code :

$( "div" ).on( "click", function(){
  $( this ).css({
      width: function( index, value ) {
	        return parseFloat( value ) * 1.2;
			},
			height: function( index, value ) {
				return parseFloat( value ) * 1.2;
			}
	});
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now