Opinion: in HTML, Possible Duplicate IDs or Non-Standard Attributes?

后端 未结 10 1987
说谎
说谎 2020-12-17 22:49

It seems pretty common to want to let your javascript know a particular dom node corresponds to a record in the database. So, how do you do it?

One way I\'ve seen t

10条回答
  •  遥遥无期
    2020-12-17 23:19

    Keeping track of your data via the DOM seems shaky to me; remember, those IDs are global variables, so if there's any chance somebody else's script can find its way onto your page, it's vulnerable. For best results, load your data into an object within an anonymous function and write the table (or the big nested list of DIVs) afterwards.

提交回复
热议问题