Best way to add metadata to HTML elements

前端 未结 6 2267
孤独总比滥情好
孤独总比滥情好 2021-02-07 04:35

I\'m trying to put together a way of marking up various components in HTML that get parsed by a jQuery script and created when the page loads.

For example, at the moment

6条回答
  •  不要未来只要你来
    2021-02-07 04:58

    Go ahead and use an attribute for this, but use a data- prefix on it. Attributes with the prefix data- are explicitly allowed on all elements as of HTML5. Example:

    
    

    It works today in all browsers, and because it's now specified behavior, it's future-proofed.

提交回复
热议问题