Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data attributes #4

Open
oliverjam opened this issue Jul 10, 2020 · 0 comments
Open

Data attributes #4

oliverjam opened this issue Jul 10, 2020 · 0 comments

Comments

@oliverjam
Copy link

I like the way you've used data-attributes to connect your HTML elements to the JS. You could actually go a step further and pass values using your data-attributes. E.g. instead of using the text content of the buttons here

calculator.chooseOperation(button.innerText)

You could pass the value of the button as data-number="4" etc, then access that with button.dataset.number. That way your JS implementation isn't so tied up with how the HTML is written. E.g. if you wanted the buttons to contain icons, or numbers written as words ("four")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant