Is it alright to add custom Html attributes?

前端 未结 11 811
醉梦人生
醉梦人生 2020-12-14 02:23

I have a site I\'m working on where I want to mark if a row of data has been changed. If something has been changed in that row I would mark it with a custom attribute like

11条回答
  •  鱼传尺愫
    2020-12-14 02:57

    Sticking to the standards for the sake of sticking to the standards is a bad reason to stick to standards.

    Your page specifies the DTD, your server specifies the mimetype. As long as you aren't sending real xhtml there is no reason not use expando attributes in this way. It can be very helpful.

    Ok so your page won't 'validate' if you need to care about that then don't do it.

    Just don't be seduced by IEs 'conveniant' elem.isDirty method of accessing such values. Always use elem.getAttribute('isDirty') to access the value.

提交回复
热议问题