텍스트 영역 내용이 변경되었는지 감지

  • 제이쿼리 방식
// 자바스크립트

$(document).ready(function() {
    $('#story').on('input', (event) => alert('Changed!
')); });
// HTML

<textarea id="story" name="story" rows="5" cols="33">
Once upon a time…
</textarea>

  • 자바스크립트 방식
//자바스크립트

document.getElementById("story")
    .addEventListener("input", (event) => alert("Changed!
"));
//HTML

<textarea id="story" name="story" rows="5" cols="33">
Once upon a time…
</textarea>

참조

https://www.techiedelight.com/ko/detect-if-textarea-content-changed-javascript/