관리 메뉴

제뉴어리의 모든것

텍스트 영역 콘텐츠가 변경되었는지 감지 본문

javascript

텍스트 영역 콘텐츠가 변경되었는지 감지

제뉴어리맨 2023. 4. 18. 01:52
  • JQuery 방법
// 자바스크립트

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

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

 

 

 

  • JavaScript 방법
//자바스크립트

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/