修改伪元素content

第一种方法:  利用 标签的data-* 属性和content:attr(data-*) 结合

CSS

.refresh-item-list {
  margin: 0 1rem 1rem;
  box-shadow: 0 0 4px 0 rgba(38, 49, 190, 0.2);
  border-radius: 8px;
  &:before {
    content: attr(data-content-before);
    position: absolute;
    top: -30px;
  }
}

HTML

 <div className="refresh-item-list" data-content-before="下拉刷新">
     xxx
 </div>

JS

const list = document.querySelector('.refresh-item-list');
list.attributes[1].value ='要修改的值';

第二种方法:

 

posted @ 2021-04-26 15:32  一路向北√  阅读(266)  评论(0编辑  收藏  举报

web应用开发&研究 -

业精于勤而荒于嬉。

工作,使我快乐。


Font Awesome | Respond.js | Bootstrap中文网