I’ve had bugs with javascript get data attribute too! Turns out I was mixing up hyphen-case and camelCase.
`.dataset` converts `data-my-attr` to `myAttr`, while `getAttribute()` keeps it as-is.
So if your code’s buggy, check your casing!
MDN has a great guide on this—worth a peek.
`.dataset` converts `data-my-attr` to `myAttr`, while `getAttribute()` keeps it as-is.
So if your code’s buggy, check your casing!
MDN has a great guide on this—worth a peek.
