Skip to content Skip to sidebar Skip to footer

Contenteditable Click Anywhere Around Element And It's Selected In Chrome

In Chrome I have a simple contenteditable='true' span, and if the user clicks anywhere around it, the cursor shows up and he/she can start editing. This is annoying b/c I only wan

Solution 1:

I strongly suspect it's just a WebKit thing. You can work around it though by making the span contenteditable only when it's clicked

Demo: http://jsfiddle.net/timdown/nV4gp/

HTML:

<body><spanid="hello">Hello World</span></body>

JS:

document.getElementById("hello").onclick = function(evt) {
    if (!this.isContentEditable) {
        this.contentEditable = "true";
        this.focus();
    }
};

Post a Comment for "Contenteditable Click Anywhere Around Element And It's Selected In Chrome"