@Dr-Wrong-Mo
Posted
Hi Jose,
First, layout wise, your project looks nice.
Second, with the way you have your HTML setup using regular DIVs, I would recommend using data attributes.
You can set a data attribute on each voting div, something like:
<div data-value="1" class="... rating">
You can then access the data attribute in JS:
Element.dataset.value
If your Element
is the defined as the above div, then this would return a value of 1, as declared in the HTML above.
Just a note to be clear. The data attribute doesn't need to be "value". It could be data-foo="bar"
and the JS would be Element.dataset.foo
, which would return a value of 'bar'. Basically, it is any variable name you want after data-
.
I hope this helps.
Marked as helpful
@jchapar
Posted
@Dr-Wrong-Mo Thanks Jon! I'll definitely look into refactoring my HTML when I return to continue working on the Js. Appreciate it!