I have a textarea
and iframe
whose sizes should change dynamically and in reverse directions. I'd like to achive this effect without using a frameset
or jQuery plugin. Here's the result of my attempt:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Resize</title>
<style>
textarea,
iframe {
display: block;
width: 300px;
height: 200px;
margin: 0;
border: 0;
padding: 0;
}
textarea {
background: green;
resize: none;
}
iframe {
background: blue;
}
</style>
</head>
<body>
<input id="slide" oninput="resize();" onchange="resize();" type="range" min="0" max="400" value="200">
<textarea id="textarea"></textarea>
<iframe id="iframe"></iframe>
<script>
var slide = document.getElementById("slide");
var textarea = document.getElementById("textarea");
var iframe = document.getElementById("iframe");
function resize() {
var slideValue = slide.value;
textarea.style.height = slideValue + "px";
iframe.style.height = 400 - slideValue + "px";
}
</script>
</body>
</html>
I wonder if you could review my code and let me know what you think.