예시
<p class="hello">안녕</p> <script> $('.hello').html('바보'); </script>
<p class="hello">안녕</p> <script> $('.hello').css('color', 'red'); </script>
<p class="hello">안녕</p> <script> $('.hello').addClass('클래스명'); $('.hello').removeClass('클래스명'); $('.hello').toggleClass('클래스명'); </script>
<p class="hello">안녕</p> <p class="hello">안녕</p> <p class="hello">안녕</p> <script> document.querySelectorAll('.hello')[0].innerHTML = '바보'; document.querySelectorAll('.hello')[1].innerHTML = '바보'; document.querySelectorAll('.hello')[2].innerHTML = '바보'; </script>
jQuery사용시
<p class="hello">안녕</p> <p class="hello">안녕</p> <p class="hello">안녕</p> <script> $('.hello').html('바보'); </script>
<p class="hello">안녕</p> <button class="test-btn">버튼</button> <script> $('.test-btn').on('click', function(){ 어쩌구~ }); </script>
<p class="hello">안녕</p> <button class="test-btn">버튼</button> <script> $('.test-btn').on('click', function(){ $('.hello').fadeOut(); }); </script>