One particular static HTML file that I have consists of the following code:
<style>
p {
overflow-wrap: break-word;
word-break: break-word;
hyphens: auto;
}
</style>
<div id="wrapper">
<p>Insert text here</p>
</div>
<div>
<input type="checkbox" id="disableOverflowWrap">
<label for="disableOverflowWrap">Checkbox to disable p { overflow-wrap: break-word; }</label>
</div>
I'm wondering how I can attach an event listener to the checkbox element in order to remove overflow-wrap: break-word;
once it is selected?
A snippet of code that I've experimented with is as follows, but unfortunately, it doesn't seem to work:
<script>
const x = document.querySelector('#disableOverflowWrap');
x.addEventListener('click', () => {
const y = document.querySelector('p');
y.removeProperty('overflow-wrap');
});
</script>