Filter element based on .data() key/value

前端 未结 5 1474
庸人自扰
庸人自扰 2020-12-12 13:08

Say I have 4 div elements with class .navlink, which, when clicked, use .data() to set a key called \'selected\', to a value of

5条回答
  •  悲哀的现实
    2020-12-12 14:08

    Sounds like more work than its worth.

    1) Why not just have a single JavaScript variable that stores a reference to the currently selected element\jQuery object.

    2) Why not add a class to the currently selected element. Then you could query the DOM for the ".active" class or something.

提交回复
热议问题