Toggle Button
Sample:
Code:
<button type="button" aria-pressed="true">
Add to favourites
</button>
<script>
const button = document.querySelector('button')
button.addEventListener('click', e => {
const isPressed = button.getAttribute('aria-pressed') === "true"
button.setAttribute('aria-pressed', !isPressed)
})
</script>