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

后端 未结 6 603
日久生厌
日久生厌 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:40

    I don't believe it's bad practice as such, it's certainly very convenient and is exactly what you would do in an xml environment. More important is the nature of the information you hold in those custom attributes and how they are used within your code.

    A nicer alternative would be to hold the data in different way for example the data() functionality of jQuery.

提交回复
热议问题