I want to trigger an onClick event for an entire class of elements. Normally, I would do something like this:
$(".classy").click(function(){
console.log("Replace this line with something useful!");
});
However, every element of this class has distinct data-attributes that I want to use inside the onClick function. For example:
<div className="classy" data-num={100}></div>
<div className="classy" data-num={931}></div>
<div className="classy" data-num={777}></div>
On the click of each element, I would want to log the data-num value. Is there any way to do this with jQuery's .click?
data-numof thedivyou click right.?this.dataset.numinside the event handlerthis.