기본적으로이 코드 중 일부를 다듬 으려하지만이 방법을 잘 모릅니다. 9 개의 DIV가 다른 지점에 절대적으로 배치되었습니다. 그들은 모두 회색이지만 끌려 가면 DIV가 사라지고 페이드 아웃되고 해당 DIV가 페이드 인합니다.이 방법을 쓸 수있는 더 좋은 방법이 있습니까?이 jQuery 함수를 작성하는 더 나은 방법은?
$('#l1').hover(function() {
$(this).fadeOut('300');
$('#l1c').fadeIn('300')
});
$('#l2').hover(function() {
$(this).fadeOut('300');
$('#l2c').fadeIn('300')
});
$('#l3').hover(function() {
$(this).fadeOut('300');
$('#l3c').fadeIn('300')
});
$('#l4').hover(function() {
$(this).fadeOut('300');
$('#l4c').fadeIn('300')
});
$('#l5').hover(function() {
$(this).fadeOut('300');
$('#l5c').fadeIn('300')
});
$('#l6').hover(function() {
$(this).fadeOut('300');
$('#l6c').fadeIn('300')
});
$('#l7').hover(function() {
$(this).fadeOut('300');
$('#l7c').fadeIn('300')
});
$('#l7').hover(function() {
$(this).fadeOut('300');
$('#l7c').fadeIn('300')
});
$('#l1c').mouseout(function() {
$(this).fadeOut('300');
$('#l1').fadeIn('300')
});
$('#l2c').mouseout(function() {
$(this).fadeOut('300');
$('#l2').fadeIn('300')
});
$('#l3c').mouseout(function() {
$(this).fadeOut('300');
$('#l3').fadeIn('300')
});
$('#l4c').mouseout(function() {
$(this).fadeOut('300');
$('#l4').fadeIn('300')
});
$('#l5c').mouseout(function() {
$(this).fadeOut('300');
$('#l5').fadeIn('300')
});
$('#l6c').mouseout(function() {
$(this).fadeOut('300');
$('#l6').fadeIn('300')
});
$('#l7c').mouseout(function() {
$(this).fadeOut('300');
$('#l7').fadeIn('300')
});
두 가지 유형의 div에 대해 두 개의 클래스를 추가 할 수 있습니까? 그렇게하면 훨씬 쉬울 것입니다. – sje397
반복 패턴을 보았습니다. /// 그래서 클럽 코드 – kobe