I've simplified my code here to show that I have a value which is passed in to "mydiv1" which is always a number. I would like to be able to reference this to perform actions depending on whether it's negative or positive, but it must be being seen as a string. Is there any way this value can be got as a number? All topics i've seen such as parseInt() seem to relate to when a variable is specified rather than got from the html.
<html>
<head>
<script type="text/javascript">
function myFunction() {
var firstDivContent = document.getElementById('mydiv1');
// var firstDivContent = "23";
if (firstDivContent > 0) {
alert('positive')
}
else if (firstDivContent < 0) {
alert ('negative')
}
}
</script>
</head>
<body onload="myFunction();">
<div id="mydiv1">23</div>
</body>
</html>