Button is not working

I’m beginner at web programming and now making website using framework 7
I would like to create a cart page, where articles could be saved and deleted before check out

I’m doing it following youtube tutorial to make cart-page

I made java-script file for cart page and create delete button

Code is the following:

console.log(“storejs”)

var removeCartItemButtons = document.getElementsByClassName(‘button-remove’);
console.log(removeCartItemButtons)

for (var i = 0; i < removeCartItemButtons.length; i++){
var button = removeCartItemButtons[i]
button.addEventListener(‘click’, function() {
console.log(“clicked”)
})
}

If I click the remove button, log (clicked) should be displayed but It doesn’t work

You can also see my code in the following link:

It works on black page without framework7 but doesnt work on framework7-core

For starters, don’t put the event listener inside a for/next loop. Put it outside it.

You would be better to have one event listener for a button click, and then read a data property to discover which specific button had been clicked.

Thanks for your reply

I can’t understand why this code is just working on black html, not on framework7-core

I checked that this code is working and shows console.log ("clicked) when clicking button

Is it because your file is called store.js and now Framework7 has a dependancy to a file named ‘store.js’? https://framework7.io/docs/store.html

Try renaming your file I guess? (Seems unlikely, as the F7 Store could potentially be named anything, but worth checking).

Could also try renaming your button variable to something more specific, in case F7 also uses that variable.