salmonmoose salmonmoose - 1 year ago 76
HTML Question

Highlight all data in a HTML Table

Is there a way to do a selection highlight over all elements in a HTML Table?

I want to be able to have data displayed in a tabular form, and the user to be able to click a button to select the relevant data to copy and paste into the spreadsheet of their choosing.

Answer Source

Try this:

function selectAll(parentNode) {
    var sel;
    // IE
    if (document.selection) {
        sel = document.body.createTextRange();
    } else {
        sel = document.createRange();


Test it out here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download