Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Change all elements BUT the one clicked Jquery.

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #44835
    Anonymous
    Inactive

    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.

    #135373
    Alen
    Participant

    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/

    #135375
    Anonymous
    Inactive

    Works perfectly, Thank you.

    #135401
    CrocoDillon
    Participant

    `$(‘.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)
  • The forum ‘CSS’ is closed to new topics and replies.