Valentin BEAULE Valentin BEAULE - 4 months ago 18x
jQuery Question

Select the value of a TD on click to ease copy

I want to select onclick the innerHTML of a td so the user can just do ctrl+C to copy the content.

I tried many combination and I can't find a way. However it seams to work on inputs with a simple


Adding a focus don't effect anything, and the .select() send and error:

document.getElementById(...).select is not a function

So how can I do with a td element?
I don't mind if it's not working on IE.


You can select text of td when it clicked.

    var range = document.createRange();
    var sel = window.getSelection(); 
table, tr, td {
    border: 1px solid black;
<script src=""></script>