I am experimenting with styling my textarea using a combination of JAVASCRIPT and CSS. The goal is to make it expand in size from 20px height to 120px height when clicked, using
document.getElementById("tweet_area")
. However, I am facing an issue where the textarea expands upon any click on the page, rather than just when clicking the textarea itself. Can someone assist me with this? I am new to JavaScript.
<script language="javascript">
document.onclick=changeElement;
function changeElement() {
var textarea = document.getElementById("tweet_area");
textarea.style.backgroundColor="#fff";
textarea.style.width="565px";
textarea.style.color="#000";
textarea.style.height="120px";
textarea.style.paddingLeft="1px";
textarea.style.paddingTop="1px";
textarea.style.fontFamily="Tahoma";
textarea.style.fontSize="10pt";
textarea.style.border="groove 1px #e5eaf1";
textarea.style.position="inherit";
textarea.style.textDecoration="none";
}
</script>
<style type="text/css">
#tweet_area{
width:565px;
height:25px;
overflow:hidden;
margin:1px auto;
font-family:Tahoma;
font-size:10pt;
font-weight:400px;
color:#000;
max-width:565px;
min-width:565px;
min-height:25px;
max-height:120px;
border:groove 1px #e5eaf1;
padding-right:10px;
}
</style>