I am fairly new to jQuery and still trying to wrap my head around selectors and jQuery's method for accessing objects. I could use a little help on this problem. I am sure it is easy.
I am trying to modify the jdMenu plugin to use image rollovers on the top level list items. I create an object with the rollover on state url for the images. I use this object to preload the images. This part works fine. Then inside the hoverOver and hoverOut functions in jdMenu I need to access the images url from the preloadimages object. This works fine if I do it like this: $.preloadimages.companyinfo, but I need to substitute the company info part for whatever the img id is for the img that is being hovered over. Like this: $.preloadimages. This would be a lot easier If I could just programmatically build the url's of the images. My only problem is I am using a system that generates image urls when you upload them. The image url is long and cryptic and can not be predicted. I hope this makes sense. Here is the portion of my code that is relavant. See comments in the code for more explanation of my problem. Thank you in advance for any advice you may have. $.preloadimages = { companyinfo: "companyinfo_on.gif", departments: "departments_on.gif", programs: "Programs_on.gif", hr: "HR_on1.gif", stores: "Stores_on.gif", weather: "OfficeWeather_on.gif" } $.each( preload, function(i, n){ $.log( "Name: " + i + ", image: " + n ); img = new Image(); img.src = n; }); //hoverOver function from JdMenu plugin function hoverOver() { var c = $(this).parent().is('.' + CSSR) ? CSSB : CSSH; $(this).addClass(c).find('> a').addClass(c); /////// the code I added $(this).children("img.rollover").each( function() { var id = $(this).attr("id"); //the line below works var image = $.preloadimages.companyinfo //how do i tack on the id variable to the $.preloadimages here so that I can access the items in the object. I can't get this to work. var image = $.preloadimages.id $(this).attr( "src", image ); }); ///////// if (this.$timer) { clearTimeout(this.$timer); } this.$size = $('> ul', this).size(); if (this.$size > 0) { var ul = $('> ul', this)[0]; if (!$(ul).is(':visible')) { this.$timer = setTimeout(function() { if (!$(ul).is(':visible')) { show(ul); } }, DELAY); } } }; -- View this message in context: http://www.nabble.com/Help-getting-object-items-tf3279641.html#a9121453 Sent from the JQuery mailing list archive at Nabble.com. _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/