The selector passed to $ function is a string, so you need to concatenate whatever variables you want into the string:
$("#central img:not([id="+thefirst+"])").hide(); this actually could be much clearer: $('#central img').not("#"+thefirst).hide(); the same applies to your 'href' var. sds, - ricardo On Nov 25, 8:26 pm, Jeremy Carlson <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm just starting to explore using jQuery. Like it so far, but I'm > totally thrown by this. > > On a page, I'm trying to hide all images in a set except the first > one. Then, when you click on a menu link, another should fade in, and > all others fade out. > > The second part works - when you click on a link tag, the image w/ the > ID listed as the href of the link fades in, and any others that are > visible fade out. I'm using this: > > $("#central img:not([id=href])").fadeOut("slow"); > > So I copied that syntax to the initial .ready function, like this: > > $("#central img:not([id=thefirst])").hide(); > > This variable ('thefirst') is created using jQuery.url.attr("anchor"), > whereas 'href' is created using $(this).attr("href"), where (this) > refers to the associated link. I think the key has to be there > somehow, but I don't see it. > > I've posted this page athttp://jeremycarlson.com/test/jq/portfolio.htm > (there are several alerts thrown in so I can see what the variables > are at any given time, which makes the load a little odd) I just can't > see what's going wrong. > > Thanks in advance for any help anyone might offer. > > Here is the full js code: > > <script type="text/javascript" src="jquery-1.2.6.js"></script> > <script type="text/javascript" > src="jquery.url.packed.js"></script> > <script type="text/javascript"> > > $(document).ready(function(){ > > if(undefined != jQuery.url.attr("anchor")) { > var anchor = jQuery.url.attr("anchor"); > var thefirst = "#"+anchor; > alert (thefirst); > } else { > var thefirst = "#view1"; > alert(thefirst); > } > > $("#central img:not([id=thefirst])").hide(); > > $("#central img").css({position:"absolute"}); > > $("#view-menu a").click(function(event){ > $(this).focus(); > var href = $(this).attr("href"); > alert(href); > $("#central > img:not([id=href])").fadeOut("slow"); > $(href).fadeIn("slow"); > event.PreventDefault; > }); > }); > </script> > > Thank you, > Jeremy Carlson