I’d like to have a checkbox that, when checked, will enable a <textarea>’s spellcheck attribute and vice-versa.
However, I’m not sure if this is possible.
This is my code so far:
document.getElementById('sampleCheckbox').addEventListener('click', function() {
let textArea = document.getElementById('sampleTextarea');
textArea.setAttribute('spellcheck', 'true') = !textArea.setAttribute('spellcheck', 'false')
});
Enable/Disable Spellcheck <input type="checkbox" id="sampleCheckbox" checked>
<br>
<br>
<textarea spellcheck="true" rows="5" cols="50" id="sampleTextarea">sadadadadadsasamkdajdakmkmxzcm</textarea>
How do I achieve this goal?