這裡提供一個很簡單的作法:
HTML
<div class="box" some-attribute-name=""></div>
CSS
.box::before{
content= attr(some-attribute-name);
}
JavaScript
var box = document.querySelector('.box');
box.setAttribute('some-attribute','要新增的屬性值');
這裡提供一個很簡單的作法:
<div class="box" some-attribute-name=""></div>
.box::before{
content= attr(some-attribute-name);
}
var box = document.querySelector('.box');
box.setAttribute('some-attribute','要新增的屬性值');