+ 3
How to get Value of Button
I am trying to create a calculator. I want whenever we clicked to button it have to show in that black screen our clicked value.Below I will attach my code https://code.sololearn.com/WxSVt7SKpTnN/?ref=app
6 Respuestas
+ 2
Something to keep in mind.
When you use getElementsByClassName you are asking a collection of elements, so when you try to get an individual elements value you need to state which element you are referring to, in most case it is the first element at the 0 index.
So...
document.getElementsByClassName('btn-one').value; <-- don't do this.
document.getElementsByClassName('btn-one')[0].value;<-- do this.
+ 1
Still its confusing to me because I new to JavaScript I just finished html css and I finished only the basics of JavaScript ((
+ 1
ODLNT onclick to button i want to get the number which it is presenting and store it in a variable then print it to the screen 😣
0
Javascript can be confusing. What exactly is confusing you at this moment?
0
Now I must admit I am somewhat confused.
What you are trying to do with the calculator is no different than what you have done with your card project (getPrice() function). You should follow that same concept.