How to increment div id value?

后端 未结 3 537
有刺的猬
有刺的猬 2020-12-16 04:41

I have got a task to set the menu as selected. For that I use dynamic id. So I want to increment it with respect to the selection

My code is

3条回答
  •  猫巷女王i
    2020-12-16 05:23

    Just use a class name instead of an id, you will be able to reuse the code you have just added but in this way.

     var list = $(".menu");
    

    One advice, don't do the highlighting of the item menu with javascript, do it server-side, and you can add the "activating" class directly in the HTML of the LI.

提交回复
热议问题