So I am making a carousel and I want the user to be able to swipe and see the next image. I am currently using radio inputs and want to change the property to checked once the user has swiped the container. I don't know how to access one element in my object to then add a property of checked to it. Any help would be appreciated! Thanks in advance!
let touchstartX = 0
let touchendX = 0
let radio = document.getElementsByClassName('radio')
console.log(radio)
function checkDirection() {
if (touchendX < touchstartX) {
alert('swiped left')
}
if (touchendX > touchstartX) alert('swiped right!')
}
document.addEventListener('touchstart', e => {
touchstartX = e.changedTouches[0].screenX
})
document.addEventListener('touchend', e => {
touchendX = e.changedTouches[0].screenX
for (let i = 0; i < radio.length; i++) {
if (touchendX < touchstartX) {
console.log(radio[i])
checkDirection()
}
}
});