I need ($(“#flip”).click slideToggle ) to perform several times on the same page with same
ID

后端 未结 1 691
死守一世寂寞
死守一世寂寞 2021-01-24 18:52

I have a FAQs page that reads from XML using XSl code, The div for the question and answer will be repeated as much as the number of records in the XML.

This is the XSL

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-24 19:56

    HTML 101: Ids are singular, you can not have more than one item with the same id!

    Use a class! Use next()

    HTML:

    XXX
    YYY
    XXX
    YYY
    XXX
    YYY

    JavaScript:

    $(document).on("click",".question", function(){
         $(this).next().toggle();   
    });
    

    Example

    http://jsfiddle.net/8xvTM/1/

    0 讨论(0)
提交回复
热议问题