I need help with my JQuery calculator

I need help with my JQuery calculator
0

#1

Front End Libraries Projects - Build a JavaScript Calculator

When I click on something in my calculator, it either just logs that button’s id and the only working button is AC and CE, or nothing happens. I tried changing this.id to this.value and it didn’t work at all. Can someone tell me what am I doing wrong?

here’s my code:


#2

Looking at your anchor click handler, if a number is clicked the if statement condition of the outer else statement evaluates to true and the following line executes.

getValue(this.id);

Do you understand what this represents? It is the anchor tag clicked. An anchor element does not have a value attribute, so when you try to reference this.value, you get undefined. Why not reference the inner text like below?

getValue($(this).text());