보통 이벤트리스너로 버튼을 클릭했을 때
~~ 이러한 코드를 실행 주세요 라는 기능을 많이 사용한다
클릭뿐 많이 아니라 이벤트리스너로 사용할 수 있는 예약어들이 있다
내가 보려고 만드는 것이니 하나하나씩 추가하겠다
click
<script>
// click
document.getElementById('id').addEventListener('click', function(){
//실행할 코드를 여기에 적어주세요
});
</script>
예를 들면 버튼을 클릭했을 때 실행할 코드~
mouseover
<script>
// mouseover
document.getElementById('id').addEventListener('mouseover', function(){
//실행할 코드를 여기에 적어주세요
});
</script>
마우스를 요소에 스윽 가져다 놓았을 때
정확히는 내가 찾은 id라는 요소 안으로 마우스가 들어왔을 때를 얘기함
input
<script>
// mouseover
document.getElementById('id').addEventListener('input', function(){
//실행할 코드를 여기에 적어주세요
});
</script>
input 창에 입력값이 들어왔을 때
'javaScript' 카테고리의 다른 글
[JS / javascript] scroll X, Y 값 구해보기 (0) | 2022.05.03 |
---|---|
[JS / javascript] if문 조건식 한번에 여러개 비교하기 (2) | 2022.04.30 |
[JS / javascript] javascript CRUD란 무엇인가? (0) | 2022.03.12 |
[JS / javascript] javascript로 animate 애니메이션 주는법 ! (0) | 2022.02.25 |
[JS / javascript] javascript array(어레이) 배열 (0) | 2022.02.22 |