Forums

Give help. Get help.

  • Anonymous
    # May 16, 2013 at 9:55 pm

    I have 10 divs. I want all to change color onclick BUT the one clicked. I know i can select all elements like this

    $(“*”).css(“background-color”,”red”);

    They all change colors but i want the one that is clicked to remain the same.

    # May 16, 2013 at 10:07 pm

    Something like this: http://codepen.io/anon/pen/shlrb

    And do not ever use `*` to select items (this select EVERYTHING). With JavaScript you want to be really specific.

    Free jQuery course: https://tutsplus.com/course/30-days-to-learn-jquery/

    Anonymous
    # May 16, 2013 at 10:29 pm

    Works perfectly, Thank you.

    # May 17, 2013 at 5:21 am

    `$(‘.it’).not($(this))` is the same as `$(‘.it’).not(this)` (the function accepts a DOM Element as well)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag