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

后端 未结 6 601
日久生厌
日久生厌 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 02:01

    It is not a best nor a good practice.

    I guess you need it for some javascript treatment. I usually solve the problem by adding custom "class" attribute, prefixed with 'js'.

    Another solution is to use the store data/retrieve data functionnality of JQuery, or the equivalent of any other framework, which imply echoing all over your generated HTML.

提交回复
热议问题