Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Automatically Select - All When Clicking On A Content Editable Element

Overview

I'm working on a tool to make ascii art. One feature I'm after is the ability to auto select a character when I click on it. This is the code I'm using for that.

Example HTML

Here's the example along with the HTML that makes it

Draw the chart
Fasten two pins

The Script

And this is the function that makes things happen :

- If you click on the Draw the chart or Fasten two pins lines in the Example section you'll see the behavior

- I tested this on a mac in safari, firefox, and chrome

- The main thing is the focusOnClick handler. I'm attaching them through the init function. Other methods would work just as well

Footnotes And References