I get 050 if I type 50 to the textbox and have 0 as the offsetTop. Why? This is the code:
alert(allspan[i].offsetTop+document.getElementById("size").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.
The return type of
.valueis a string, so you get string concatenation instead of two numbers being added.You need to use
parseInton the value.