So I am trying to get it so each time a button is pressed a circle gets wider. I have ran into the most peculiar issue, their is a block of code that when you put it in an alert() method it shows properly, however it shows as nul if you put it into a variable then display it. Here is the full code.
<!doctype html>
<html>
<head>
<title>CSS Basics</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
#circle {
width:200px;
height:200px;
border-radius:200px;
background-color:red;
}
</style>
</head>
<body>
<div id="circle">asdfasdf</div>
<button id="Saver"> Press me to save your text </button>
<input id="Text" type="text" value="test"/>
<script type="text/javascript">
var divId="circle";
var obj= document.getElementById("Saver");
var it234 = 1;
//THIS IS A COMMENT DOESNT THSI MAKE YOU HAPPY
obj.onclick=function() {
document.getElementById("circle").innerHTML = document.getElementById("Text").value;
it234 = parseInt(document.getElementById("circle").style.width.substring(0,3));
//document.getElementById("circle").style.width="300px";
alert(it234);
}
</script>
</body>
</html>
And here is the section in progress
This should work but doesnt
obj.onclick=function() {
document.getElementById("circle").innerHTML = document.getElementById("Text").value;
it234 = parseInt(document.getElementById("circle").style.width.substring(0,3));
//document.getElementById("circle").style.width="300px";
alert(it234);
}
However instead of working it shows an alert with Nan. How can I get the width of this div saved into a variable (preferably in string format)?