outer div ok, nested div ko
good morning,
I'm new to the forum. Thank you for the cool place, I just found tons of amazing stuff ;)
I wanted to ask a question about html traversing, because I've got an unsolved problem which blocks the development of one project of mine.
I post code for simplicity:
- $(document).ready(function() {
$.fn.pause = function(duration) { // funzione delay;
$(this).animate({ dummy: 1 }, duration);
return this;
};
var slideTime = 1500;
var popupFadeDelay = 1500;
var popupFadeTime = 1000;
$('.wrapper:not(#page_home)').hide();
$('#page_home .menu #home').addClass('selected');
// POPUP ASSOLVE/DISSOLVE; ---
$('#page_home .right .popupbox').pause(popupFadeDelay).fadeIn(popupFadeTime);
// ---
function activateMenuLink(clip) {
$(clip).click(function() {
var clipId = $(clip).parent().attr('id');
// $('.wrapper:not(#page_' + clipId + ')').slideUp(slideTime);
$('.wrapper:not(#page_' + clipId + ')').slideUp(slideTime, function() {
$(this).find('.popupbox').hide();
});
// $('#page_' + clipId).slideDown(slideTime);
$('#page_' + clipId).slideDown(slideTime, function() {
$(this).find('.popupbox').pause(slideTime + popupFadeDelay).fadeIn(popupFadeTime);
});
$('#page_' + clipId + ' .menu:not(#' + clipId + ')').removeClass('selected');
$('#page_' + clipId + ' .menu #' + clipId).addClass('selected');
});
}
activateMenuLink($('.menu #home a'));
// --- THE PROBLEM IS HERE --- //
alert("ok " + $('#page_collection .caption #54').attr('id')); // <--- this doesn't works :(
alert("no " + $('#page_collection .caption .subpage:not(#54)').attr('id')); // <--- this works :)
});
I know that there is a div with id "54", and many other at the same level. The alert marked with "no" works correctly (it displays all the divs except 54). The one marked "ok" responds undefined.
Hope you can help me find a solution. I suspect that the solution is right there, but I can't see it. Thank you all again.
Bye,
Luca