Is it a bad practice to add extra attributes to HTML elements?

后端 未结 6 583
日久生厌
日久生厌 2021-01-04 01:30

Sometimes I add an attribute to some of my controls. Like:

Chris Sharma

I know it

6条回答
  •  庸人自扰
    2021-01-04 01:43

    Using jquery,

    to store: $('#element_id').data('extra_tag', 'extra_info');

    to retrieve: $('#element_id').data('extra_tag');

    This was also posted @ [http://stackoverflow.com/a/16985773/2458978][1]

    [1]: How to store arbitrary data for some HTML tags

提交回复
热议问题