admin管理员组

文章数量:1289509

When editing an element with the contenteditable attribute I want the background color of that element to change colors. For example, if the element background color was dark grey I would want it to turn white while editing the element and then reset back to dark grey when done editing.

When editing an element with the contenteditable attribute I want the background color of that element to change colors. For example, if the element background color was dark grey I would want it to turn white while editing the element and then reset back to dark grey when done editing.

Share Improve this question asked Aug 1, 2013 at 21:13 Sunday1290Sunday1290 751 silver badge6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

You can use this CSS:

[contenteditable="true"] {
    background-color: grey;
}

[contenteditable="true"]:focus {
    background-color: white;
}

Here's the JSFiddle.

Use something like this.

[contenteditable]:focus {
    background: #fff;
}

本文标签: javascriptContenteditablechange background color when editingStack Overflow