jquery 객체 (html 요소 컬렉션)를 저장하지만 다른 함수에서 객체를 참조 할 때 'undefined'로 돌아옵니다! 여기 내 코드는 다음과 같습니다콜백 내에서 jQuery 객체를 참조 할 수없는 이유는 무엇입니까?
this.container = $('#slide-menu'), // The menu container (e.g. a UL)
this.items = this.container.find('.menu-item'); // The menu items (e.g. all li's)
this.links = this.items.find('.link'); // The menu links
this.getCurrent(); // Set the current menu-item
this.getPrev(); // Set the previous menu-item
this.getNext(); // Set the next menu-item
console.log(this.items); // !!! The items exist here !!!
// Setup the menu items click events:
this.items.bind('click', function(e) {
console.log(this.items); // !!! But not here !!! ???
e.preventDefault();
o = $(e.currentTarget); // Set jquery object
if (!o.hasClass('active')) { // Prevent action on current menu-item
this.items.find('.active').removeClass('active'); // Remove the current active menu-item
o.addClass('active'); // Set new active menu item
사람은 나를 미치게 그리고 지금까지 내가 볼 수있는이 가능하지 않아야하기 때문에 이런 일이 왜 어떤 생각을 가지고있다. 자바 스크립트가 깨졌습니다?! 흠, 어떻게 생각하세요?
Doh! 네가 절대적으로 옳다. 루키 실수는 미안하다. 정말 고마워!! – Chris
롤 - 자바 스크립트가 깨졌습니다? > jk. 다시 한 번 감사드립니다. – Chris