实现div里面有placeholder形式

样式中设置content为元素的data-值

    p{
      color: deepskyblue;
    }
    p:before{
      content: attr(data-beforeContent);
      color: darkred;
    }

然后js修改

  $('p').on('click',function(){
    $(this).attr('data-beforeContent','我被点击了');
  });

 

posted @ 2019-09-04 14:42  古月大叔  阅读(987)  评论(0编辑  收藏  举报