$("요소").addClass("클래스명");
addClass() 예제
<script src="http://code.jquery.com/jquery-latest.js"></script> <style> table,th,td {border:1px solid red; border-collapse:collapse;} th,td {padding:50px;} .hover {background:red;}</style> <table id='hz' class=''> <tr><th class=''>홈짱닷컴</th></tr> <tr><td class=''>Homzzang.com</td></tr> </table> <script> $(document).ready(function(){ $( "td" ).hover( function() { $( this ).addClass( "hover" ); }, function() { $( this ).removeClass( "hover" ); } ); }); </script> 결과보기
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
table,th,td {border:1px solid red; border-collapse:collapse;}
th,td {padding:50px;}
.hover {background:red;}</style>
<table id='hz' class=''>
<tr><th class=''>홈짱닷컴</th></tr>
<tr><td class=''>Homzzang.com</td></tr>
</table>
<script>
$(document).ready(function(){
$( "td" ).hover(
function() { $( this ).addClass( "hover" ); },
function() { $( this ).removeClass( "hover" ); }
);
});
</script>
결과보기