Skip to content

Instantly share code, notes, and snippets.

@anjanaraveendra
Last active April 15, 2018 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjanaraveendra/ff33a18c00a1393f714ed5bd7ec2a6f0 to your computer and use it in GitHub Desktop.
Save anjanaraveendra/ff33a18c00a1393f714ed5bd7ec2a6f0 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 100px;
height: 100px;
border: 10px solid green;
padding: 25px;
margin: 25px;
}
</style>
</head>
<body>
<div style="text-align: center;margin-top: 150px;">
<input type="text" id="width" name="Width" placeholder="Width">
<input type="text" id="height" name="Height" placeholder="Height">
<button class="submit" onclick="myFunction()">Submit</button>
<div id="box" style="margin-left: 44%;"></div>
<div id="box-dimension-text">I am of height 100px and widht 100px</div>
</div>
</body>
</html>
<script type="text/javascript">
function myFunction() {
var height = document.getElementById("width").value + 'px';
var width = document.getElementById("height").value + 'px';
tobeChanged = document.getElementById("box");
tobeChanged.style.height = height;
tobeChanged.style.width = width;
document.getElementById("box-dimension-text").innerHTML = "I am of height " + height + " and" + " width " + width
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment