첫 번째 게시물, 첫 번째 질문입니다.메뉴 옵션이 전환됩니까?
나는 jQuery 초심자이므로 나와 함께 곰. 3 가지 옵션이있는 메뉴가 있습니다. 옵션을 활성화/활성화 할 때 비활성화/비활성화 (비활성화 할 때 * _deactivate() 함수를 각각 실행) 코드를 전환해야합니다. 깔끔한 메뉴를 갖추기 위해 애니메이션의 시작/종료를 만들었습니다. 일부 게시물을 확인했지만 내 문제에 대한 솔루션을 적용하지 못했습니다.
메뉴의 코드 :
// Menu button "A Empresa" mouse events ├───────────────────────────────────────────────────────────────────┤
$('#aEmpresa').on('mouseenter', function(){
$(this).css({'cursor':'pointer'});
$("#aEmpresa p").animate({'color':'#EF7F1A'}, 150);
$("#aEmpresa_underline").animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
});
$('#aEmpresa').on('mouseleave', function(){
$("#aEmpresa p").animate({'color':'#C5C6C6'}, 150);
$("#aEmpresa_underline").stop(true).animate({'background-position-x':'0px', 'background-position-y':'0px'}, 150);
});
$('#aEmpresa').on('click', function(){
$("#aEmpresa p").animate({'color':'#000000'}, 150);
$("#aEmpresa p").css({'font-weight':'bold'}, 150);
$('#aEmpresa_underline').animate({'background-position-x':'0px', 'background-position-y':'-22px'}, 150);
$(this).unbind('mouseenter mouseleave');
$(this).css({'cursor':'default'});
});
function aEmpresa_deactivate(){
$('#aEmpresa_underline').animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
$("#aEmpresa p").animate({'color':'#EF7F1A'}, 150,
function(){
$('#aEmpresa_underline').animate({'background-position-x':'0px', 'background-position-y':'-22px'}, 150);
$("#aEmpresa p").animate({'color':'#C5C6C6'}, 150);
$("#aEmpresa p").css({'font-weight':'normal'}, 150,
function(){
$('#aEmpresa').on();
$(this).css({'cursor':'pointer'});
}
);
}
);
}
// Menu button "A Nossa Arte" mouse events ├────────────────────────────────────────────────────────────────┤
$('#aNossaArte').on('mouseenter', function(){
$(this).css({'cursor':'pointer'});
$("#aNossaArte p").animate({'color':'#EF7F1A'}, 150);
$("#aNossaArte_underline").animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
});
$('#aNossaArte').on('mouseleave', function(){
$("#aNossaArte p").animate({'color':'#C5C6C6'}, 150);
$("#aNossaArte_underline").stop(true).animate({'background-position-x':'0px', 'background-position-y':'0px'}, 150);
});
$('#aNossaArte').on('click', function(){
$("#aNossaArte p").animate({'color':'#000000'}, 150);
$("#aNossaArte p").css({'font-weight':'bold'}, 150);
$('#aNossaArte_underline').animate({'background-position-x':'0px', 'background-position-y':'-22px'}, 150);
$(this).unbind('mouseenter mouseleave');
$(this).css({'cursor':'default'});
});
function aNossaArte_deactivate(){
$('#aNossaArte_underline').animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
$("#aNossaArte p").animate({'color':'#EF7F1A'}, 150,
function(){
$('#aEmpresa_underline').animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
$("#aNossaArte p").animate({'color':'#C5C6C6'}, 150);
$("#aNossaArte p").css({'font-weight':'normal'}, 150,
function(){
$('#aNossaArte').on();
$(this).css({'cursor':'pointer'});
}
);
}
);
}
// Menu button "Contactos" mouse events ├───────────────────────────────────────────────────────────────────┤
$('#contactos').on('mouseenter', function(){
$(this).css({'cursor':'pointer'});
$("#contactos p").animate({'color':'#EF7F1A'}, 150);
$("#contactos_underline").animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
});
$('#contactos').on('mouseleave', function(){
$("#contactos p").animate({'color':'#C5C6C6'}, 150);
$("#contactos_underline").stop(true).animate({'background-position-x':'0px', 'background-position-y':'0px'}, 150);
});
$('#contactos').on('click', function(){
$("#contactos p").animate({'color':'#000000'}, 150);
$("#contactos p").css({'font-weight':'bold'}, 150);
$('#contactos_underline').animate({'background-position-x':'0px', 'background-position-y':'-22px'}, 150);
$(this).unbind('mouseenter mouseleave');
$(this).css({'cursor':'default'});
});
function contactos_deactivate(){
$('#contactos_underline').animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
$('#contactos p').animate({'color':'#EF7F1A'}, 150,
function(){
$('#aEmpresa_underline').animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
$("#contactos p").animate({'color':'#C5C6C6'}, 150);
$("#contactos p").css({'font-weight':'normal'}, 150,
function(){
$('#contactos').on();
$(this).css({'cursor':'pointer'});
}
);
}
);
}
// Running menu for the first time - aEmpresa ├─────────────────────────────────────────────────────────────┤
function aEmpresa_runFirstTime(){
$('#aEmpresa_underline').animate({'background-position-x':'0px', 'background-position-y':'-10px'}, 150);
$("#aEmpresa p").animate({'color':'#EF7F1A'}, 150,
function(){
$('#aEmpresa_underline').animate({'background-position-x':'0px', 'background-position-y':'-22px'}, 150);
$("#aEmpresa p").animate({'color':'#000000'}, 150);
$("#aEmpresa p").css({'font-weight':'bold'}, 150,
function(){
$('#aEmpresa').off();
$(this).css({'cursor':'default'});
}
);
}
);
}
// Running first time
aEmpresa_runFirstTime();
페드로
P.S. 처음 실행하면 첫 번째 옵션이 자동으로 활성화됩니다.
그것은 잘 작동합니다. :) 나는 그것을 공부할 것이다. 로드니 고마워. – Pedro
안녕하세요. 지금은 단 한가지 문제가 있습니다 ... 각 메뉴 옵션의 존경 html 파일 인 aEmpresa.html, aNossaArte.html 및 contactos.html의 기본 HTML 파일에서 "main content"div에 .load()를 수행해야합니다. #mainContent. 어떻게해야합니까? – Pedro
글쎄, 이미 한 것을 수정하고 싶다면 각 메뉴 div에'data-href = "aEmpresa.html"(etc)를 추가하면됩니다. 그런 다음,'click' 핸들러의 끝에서 '$ ("# mainContent")를 추가하십시오 load ($ (this) .data ("href")), ' 'false false; –