• 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


    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:

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

    Free jQuery course:

    # May 16, 2013 at 10:17 pm

    This reply has been reported for inappropriate content.

    $('.it').not($(this)) will give all matched items except the one clicked. However, in this instance I would do exactly what @AlenAbdula has posted.

    # 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 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.