Forums

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

Home Forums JavaScript [Solved] Click syntax

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31713
    noahgelman
    Participant

    I want to put a click function on an element and it’s siblings, how would I do that.
    Putting it on an element is easy, but how to target both it AND it’s siblings is lost on me.

    #59440
    jamygolden
    Member

    This simple function will solve all your problems =) : andSelf()

    $('#example').siblings().andSelf().css('border', '3px solid red');
    #59006
    noahgelman
    Participant

    How the heck was I not aware of .andSelf() ?
    I never even noticed it in the jQuery API
    Yeah, this solves my problem just fine, thank you

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.