I have data-segment attribute in my body tag that is changed by a slider. I need to trigger a function based on the value of this, when it is changed.
I’m not sure how to attach an event listener in this case though?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
`There is no reliable cross-browser way to receive an event when a DOM node attribute is changed. Some browsers support “DOM mutation events”, but you shouldn’t rely on them, and you may Google that phrase to learn about the ill-fated history of that technology.
If the slider control does not fire a custom event (I would think most modern ones do), then your best bet is to set up a
setInterval()method to poll the value.