contenteditable – select all on double click  [ 758 views ]

Goal: don’t be fool, do it easy

A have a DIV with contenteditable=”true” attribute. Like a textbox but not really. I want to select all the content with a double click on it. With jQuery like this:

  var myDIV = ...;
  myDIV.on({
    dblclick: function(){
      // one line code coming
      document.execCommand('selectAll', false, null);
    }
  });

… so do you know better than this solution? …
I have read many scientific solution for this problem. Don’t be fool, just do it easy…

#sidebar a { color:#fff; } #sidebar ul ul li { color: #DEF585; } #sidebar h2 { color: #fff; } #sidebar ul p, #sidebar ul select { color: #BEDDBE; } #backfly { background: url(images/golfBallWallPaper.jpg) left bottom fixed repeat-x #65a51d; }