jQuery toggle class on child element

后端 未结 4 1240
太阳男子
太阳男子 2020-12-22 00:34

I have list of links, and if you click on any of them, it will toggle show/hide text below it in separate div. Also it hides all other divs if one of them is shown This code

4条回答
  •  我在风中等你
    2020-12-22 01:14

    Using parent - child selectors in jQuery is quite simple...

    $("a > div > i")
    

    will select the i element, that is a child of the div element, that is a child of the a element. http://www.w3schools.com/jquery/sel_parent_child.asp.

    If the elements are not going to be direct descendants, as in your example, remove the greater than sign.

    $("a div i")
    

提交回复
热议问题