Thanks very much for your help Brian. That works, but I think the problem may go deeper than I thought! I've put up a test page.
I'm using the "JQuery Opacity Rollover" Script as a part of the Gallerific plugin http://www.twospy.com/galleriffic/#1 To try and keep this simple, when you hover over a thumbnail, it originally went from dark to light. I've reversed the order of this in "mouseOutOpacity" & "mouseOverOpacity" on the scripts.js & jquery.opacityrollover.js, so now they are full opacity by default and half when you hover over. There is a selected class applied when you click on a thumbnail and I want to make the opacity stay at half when you click on it. There seems to be a default on all list items of the thumbs <ul> of opacity: 1; I want to change it to 0.5 when an item has a class of selected, but can't get it to work. I've tried removing the inline style first using $("#portfolio #thumbs li.selected").removeAttr("style"); But this doesn't work. Sorry for the long windedness of this post, but if anyone could even give me a hint of where to start looking, I would be really grateful. Thanks 2010/1/5 brian <zijn.digi...@gmail.com> > Just put the class in the selector instead of testing for it first: > > $("#portfolio #thumbs li.selected").css('opacity','0.5'); > > If the class doesn't exist, jQuery will do nothing (instead of > throwing an "undefined" error or similar). > > On Tue, Jan 5, 2010 at 12:45 PM, Paul Collins <pauldcoll...@gmail.com> > wrote: > > Hi all > > > > I've been stuck on this for four hours, and I still can't solve it! > > > > I am trying to check if a list item has a class of selected, then is so > > change the opacity to 0.5. Here is my code: > > > > if ($("#portfolio #thumbs ul li").hasClass(".selected")) { > > $(this).css('opacity','0.5'); > > } > > > > It seems that the "this" part isn't working, is it to do with putting it > in > > an event? > > > > Would appreciate any help > > > > > > >