HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script> <!-- <button>버튼_1</button> --> <button style="color: red;">버튼_1</button>
JS
console.clear(); let isRed = false; function changeBodyBackground() { // 방식#2 if (isRed){ $('body').css('background-color',''); } else{ $('body').css('background-color','green'); } isRed = !isRed; } //button 클릭 시 changeBodyBackground함수 실행 $('button').click(changeBodyBackground);