.addEventListener() not working?

So i’m working on a new version of my calculator http://codepen.io/Mike-was-here123/pen/QrdJdO?editors=1010

You can see i’m trying to make it so every time i click on a item, i want it to run a function called solve. I want it to .addEventListener() too all my buttons so i can get there ID’s, combine it, and eval() it for answer.

Uncaught TypeError: Cannot read property 'fn' of undefined

All my buttons are surrounded in a div with is ID “buttonRows”, any idea why it isn’t working?

I know my buttons are in row div’s, but i even tried calling by ClassName ‘row’ and it wasn’t a function.

This code was from another calculator i made, in which someone gave it to me to save time as it works for all buttons and getting there id’s. Those were in lists (ul's) and worked then.

Not feeling like redoing my html to instead making it in lists, any way i can make this event listener work in rows?

I just changed the document.getElementsById to document.getElementById and it worked, Make sure you always develop with the console open.

There is no such thing as getElementsById. There is a getElementById though. Also, make sure to add jQuery before the Bootstrap library to avoid the other error showing in your console.

1 Like