If you are simply pushing data to the screen and want to "know" what format the data is then maybe you can tag each element with the "data" attribute and set a value to it before you push it to the dom. Once you set the data attribute (e.g. data-format) to any value you like, you can than use CSS to format it and you can use JavaScript to manipulate it as well based on the value you set.
let data_format = document.querySelectorAll('[data-format]')
data_format.forEach((element) => {
console.log(`Data Format = ${element.dataset.format}`)
})
发布评论
评论(1)
如果您只是简单地将数据推到屏幕上,并想“知道”数据是什么格式,那么也许您可以使用“数据”属性标记每个元素,然后在将其推向DOM之前设置值。将数据属性(例如Data-Format)设置为您喜欢的任何值后,您可以使用CSS格式化它,并且可以根据设置的值使用JavaScript来对其进行操作。
If you are simply pushing data to the screen and want to "know" what format the data is then maybe you can tag each element with the "data" attribute and set a value to it before you push it to the dom. Once you set the data attribute (e.g. data-format) to any value you like, you can than use CSS to format it and you can use JavaScript to manipulate it as well based on the value you set.