Back Home

Open Designs

Community. Driven.

    • CommentAuthorgillweb
    • CommentTimeAug 21st 2008
     
    Anyone have any idea on how I can select all the text in an div? There are plenty of Javascript ways of doing this with a textarea but i havent found a solution for a DIV.

    I have a DIV that has an overflow: auto and specific height so I would like to add a link so the user can just click the "select all text" link and it would do just that so they could Copy it. Maybe a copy to clipboard solution?
    •  
      CommentAuthorbakercad
    • CommentTimeAug 21st 2008
     
    this should do it:
    var div = document.getElementById("divName");
    div.innerHtml (or innerText)