Multiple identical IDs in the same HTML document

后端 未结 3 1977
挽巷
挽巷 2020-12-21 06:10

I am creating a web page that includes several HTML-templates that may contain IDs. As a result the final page may contain several HTML element with the exact same ID which

3条回答
  •  猫巷女王i
    2020-12-21 06:27

    As long as you use jQuery context, e.g. $('#some-id', context), it will work fine.

    But you should really use class names instead of IDs for elements that occur more than once in a page.

提交回复
热议问题