I was directed to this page from MDN by the help documents of a code editor I am trying to use. The information seems straightforward. However, I cannot seem to get this to work. I am trying to trigger a blur when a user moves out of the text editor. Should I be able to utilize this code here? Thanks
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.3.2/tinymce.min.js"></script>
<script>
tinymce.init({
selector: '#mytextarea',
menubar: false,
statusbar: false,
toolbar: false,
height : "780"
});
</script>
</head>
<body>
<form method="post">
<textarea id="mytextarea">My contents are from</textarea>
</form>
<script>
function saveForm() {
var theParam = tinymce.get('mytextarea').getContent();
}
const mta = document.getElementById('mytextarea');
mta.addEventListener('blur', (event) => {
event.target.style.background = 'pink';
}, true);
</script>
</body>
</html>