에서 다른 동작 : 부모에jQuery를 드롭 다운 메뉴는 원하는 동작은 IE와 웹킷
- 클릭 어디 페이지 나 부모에 드롭 다운 메뉴를
- 클릭을 열고, 드롭 다운 메뉴를 닫습니다
내 jQuery 코드는 Safari & Firefox에서는 제대로 작동하지만 IE 8에서는 작동하지 않습니다. IE 8에서는 부모를 처음 클릭 할 때 드롭 다운 메뉴가 열리고 닫힙니다. 부모가 두 번 클릭하면 드롭 다운 메뉴가 열립니다. 나는 jQuery 1.6.2를 사용하고있다.
여기에 jQuery 코드 (나는 다른 방법에서 함께 자갈길 한 프랑켄슈타인의 비트는 내가 약을 읽기)이다 : 누군가가 나에게로와 같은 포인터를 줄 수 있다면
이$(function() {
/* for keeping track of what's "open" */
var activeClass = 'menu-open', showingDropdown, showingMenu, showingParent;
/* hides the current menu */
var hideMenu = function() {
if(showingDropdown) {
showingDropdown.removeClass(activeClass);
showingMenu.fadeOut(500);
}
};
/* recurse through dropdown menus */
$('.drop').each(function() {
/* track elements: menu, parent */
var dropdown = $(this);
var menu = dropdown.next('.subnav'), parent = dropdown.parent();
/* function that shows THIS menu */
var showMenu = function() {
hideMenu();
showingDropdown = dropdown.addClass('menu-open');
showingMenu = menu.show();
showingParent = parent;
};
/* function to show menu when clicked */
dropdown.attr('href','/#dropdown').bind('click',function(e) {
if(e) e.stopPropagation();
if(e) e.preventDefault();
if (dropdown.hasClass('menu-open')) {
hideMenu();
} else {
showMenu();
}
});
/* function to show menu when someone tabs to the box */
dropdown.bind('focus',function() {
showMenu();
});
});
});
이
그것은 많이 주시면 감사하겠습니다 왜 IE는 것 Webkit & Firefox와 다르게 동작해야합니다. 필자가 설명하는 것을 수행하는 기존 솔루션에 대한 링크도 훌륭합니다. jQuery/Javascript가 나의 장점이 아니기 때문에 느린 아이와 이야기하는 것처럼 설명하십시오.
첫 제안은 했습니까? 속임수. 두 번째로 제안하는 방법 ('클릭'을 방해하지 않도록 '초점'을 잡으십시오)을 수행하는 방법을 모르겠지만 이것이 가능합니다. – Florian