728x90 this1 javaScript - html의 event, this 활용하기 html 태그에서 해당 태그의 정보나 이벤트를 추출하여 js에서 사용할 수 있게 하려면, html에서 태그의 정보나 이벤트를 넘겨주어여합니다. input 태그의 이벤트와 태그 정보를 넘기기 위해 바인딩된 함수에 event와 this 키워드를 사용합니다. function testEvent($event, $element) { var strLength = $event.target.value.length; if(strLength > 40) { $event.target.value = $event.target.value.substring(0, 40); } if($event.keyCode == 13 || $event.code == "Enter") { ... } } event와 this를 각각 $even와 $this로.. 2021. 12. 13. 이전 1 다음 728x90