I have a line in my component like so...
<div className="progress" mx-auto data-value={100 - (100 * session.timeRemaining) / (session.label === "Focusing" ? focusDuration * 60: breakDuration * 60)}>
I want to do something like this...
<div className="progress" mx-auto data-value={100 - (100 * session.timeRemaining) / (session.label === "Focusing" ? focusDuration * 60: breakDuration * 60)}>
if (data-value > 0) {do stuff}
How do I monitor / check for the value of my divs data-value attribute?
CodePudding user response:
You can use getAttribute
function.
<div className="progress" mx-auto data-value={100 - (100 * session.timeRemaining) / (session.label === "Focusing" ? focusDuration * 60: breakDuration * 60)}>
document.querySelector(".progress").getAttribute('value');