I put this on the head section
var d = parseInt(document.getElementById('test').style.width);
alert(d);
But the output is NaN.
how do you get the value?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UDPATED
I think the problem is that you’ve put the code in the
<head>of your document, which means it’s looking for thetestelement right away. Unfortunately, thetestelement hasn’t been created yet, because your browser is still parsing the<head>.So, make sure that code is placed after the
testelement, and use either.offsetWidthor.clientWidth, and it should work fine.