Placeholder for contenteditable div

后端 未结 12 1564
栀梦
栀梦 2020-12-12 23:18

I have the following: FIDDLE

The placeholder works fine and dandy until you type something, ctrl + A, and delete. If you do that, th

12条回答
  •  臣服心动
    2020-12-13 00:08

    I got this solution from: https://codepen.io/flesler/pen/AEIFc

    Basically put this css code:

    [contenteditable=true]:empty:before{
      content: attr(placeholder);
      pointer-events: none;
      display: block; /* For Firefox */
    }
    

    And have the placeholder attribute in your contenteditable div.

提交回复
热议问题