이벤트 관련 메서드 2_jQuery

2022. 1. 21. 11:15ksmart_html_css_js/jQuery

728x90

- 여러 이벤트를 한번에 등록 할 수 있다.

- 여러 대상에 이벤트를 한번에 등록 할 수 있다.

 <input type="text" id="search01">
   <input type="text" id="search02">
   
   <script type="text/javascript">
   
      $(function() {
         var search = $('#search01, search02');
         console.log(search);
      
         search.keyup(function(e) {
            console.log(e.target.id);
            console.log($(this).val());
         });
         search.on('keyup blur', function() {
            console.log($(this).val());
         });
      });
  
   </script>
728x90