Skip to content
Advertisement

Click counter Bootstrap carousel button

Unfortunately, this is a remarkable stupid question. However, I could not figure out how to make a working click counter für the Bootstrap carousel button. The problem is the span element for the previous and next icons.

The button counter does not count clicks on the repective span element.

JavaScript
JavaScript

Advertisement

Answer

Add your counter data attribute to the two buttons (this is just to help initialize).

JavaScript

Check to see if click event was on button. If not it must’ve been the child span element so get the parent (the button).

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement