Re: [jQuery] Change opacity for all divs except one
Maybe something like this would work?
$(function() {
$("#thumbs div").click(function() {
$(this).toggleClass("selected");
if ($("#thumbs").data("user already selected their first favorite")) {
if ($(this).hasClass("selected")) {
$(this).fadeTo("slow", 1);
} else {
$(this).fadeTo("slow", 0.33);
}
} else {
$("#thumbs div:not(.selected)").fadeTo("slow", 0.33);
$("#thumbs").data("user already selected their first favorite", true);
}
});
})
Just a thought...
(I did not test it)
On Sat, Dec 5, 2009 at 12:10 PM, Mauricio (Maujor) Samy Silva
<css.maujor@gmail.com> wrote:
> Hi Jared
> The script is quite simply.
> Study it.
>
> jQuery:
> (document).ready(function(){
>
> $('#thumbs div').click(function() {
> $(this).find('img').css('opacity', 1);
> $(this).siblings().find('img').css('opacity', 0.5);
> });
>
> });
> HTML:
> <div id="thumbs">
> <div><a href="#"><img src="1.jpg" alt="" /></a></div>
> <div><a href="#"><img src="2.jpg" alt="" /></a></div>
> <div><a href="#"><img src="3.jpg" alt="" /></a></div>
> <div><a href="#"><img src="4.jpg" alt="" /></a></div>
> <div><a href="#"><img src="5.jpg" alt="" /></a></div>
> <div><a href="#"><img src="6.jpg" alt="" /></a></div>
> </div>
>
> Hope this help you
>
> Maurício
>
> -----Mensagem Original-----
> De: Jared
> Para: jQuery (English)
> Enviada em: sexta-feira, 4 de dezembro de 2009 19:42
> Assunto: [jQuery] Change opacity for all divs except one
> Hello all,
>
> I have a bunch of thumb nails that will be at full opacity when a user
> gets to the page. Users will be able to select their favorite. What I
> want to have happen is when a user selects their first favorite all of
> the there thumbnails will be lowered in opacity then when they select
> other favorites the opacity of that thumbnail will be brought to full.
> Each thumbnail is in a div. I am at a complete lose on how I can
> achieve this. Any help is greatly appreciated. If you need anymore
> info just ask. Thanks ins advance!
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home