JavaScript How can I make only one column of a table selectable? make only one column editable in datagridview,make read only

Can I prevent the user from highlighting one column in a table?

I have a 2-column table. Users will want to copy the content in the second column, but not the first column.

<table>
    <tr>
        <td>col1</td>
        <td>line1</td>
    </tr>
    <tr>
        <td>col1</td>
        <td>line2</td>
    </tr>
    <tr>
        <td>col1</td>
        <td>line3</td>
    </tr>
</table>

Here's a JSFiddle with an example: http://jsfiddle.net/vepq0e29/

When the user copies and pastes, I want the output to just be: line1 line2 line3 ... line7

I don't want col1 to show up or be highlighted when the user selects the table.

How can I make it so that users can only select and copy content from the second column?

Thanks!

Answer:1

You can use pseudo-elements to show the text. Text from pseudo-elements is never copied at the moment (not sure, if it'll be changed sometime).

http://jsfiddle.net/vepq0e29/3/

td:first-child:after {
    content: attr(aria-label);
}
<table>
    <tr>
        <td aria-label="col1"></td>
        <td>line1</td>
    </tr>
    <tr>
        <td aria-label="col1"></td>
        <td>line2</td>
    </tr>
    <tr>
        <td aria-label="col1"></td>
        <td>line3</td>
    </tr>
    <tr>
        <td aria-label="col1"></td>
        <td>line4</td>
    </tr>
    <tr>
        <td aria-label="col1"></td>
        <td>line5</td>
    </tr>
    <tr>
        <td aria-label="col1"></td>
        <td>line6</td>
    </tr>
    <tr>
        <td aria-label="col1"></td>
        <td>line7</td>
    </tr>
</table>
Answer:2

I have a nodeJSON string like { "Name": "Addition", "Id": "3", "ParentId": "1", "children": [ { "Name": "Two Numbers", "Id": "5", "ParentId": "3", "children": [] ...

I have a nodeJSON string like { "Name": "Addition", "Id": "3", "ParentId": "1", "children": [ { "Name": "Two Numbers", "Id": "5", "ParentId": "3", "children": [] ...

  1. parse json string java
  2. parse json string c#
  3. parse json string python
  4. parse json string to object
  5. parse json string javascript
  6. parse json string online
  7. parse json string to object java
  8. parse json string to object c#
  9. parse json string golang
  10. parse json string ruby
  11. parse json string to dictionary python
  12. parse json string swift
  13. parse json string scala
  14. parse json string to map
  15. parse json string php
  16. parse json string to map java
  17. parse json string nodejs
  18. parse json string into object java
  19. parse json string into object javascript
  20. parse json string in sql

I have 3 people's birthdays: Steve -> May 3 Mark -> October 20 Robbin -> December 5 How to loop through the remaining days of the year and find which person still has a birthday coming (IN THIS ...

I have 3 people's birthdays: Steve -> May 3 Mark -> October 20 Robbin -> December 5 How to loop through the remaining days of the year and find which person still has a birthday coming (IN THIS ...

I'm trying to load an external script while using Meteor. Currently using this code in my layout.js to some success. Meteor.startup( function() { $.getScript('js/scripts.js'); }); However, if I go ...

I'm trying to load an external script while using Meteor. Currently using this code in my layout.js to some success. Meteor.startup( function() { $.getScript('js/scripts.js'); }); However, if I go ...

  1. jquery loading external html

Let's say we have an array that can have a length of 1 to ?? We have a way of navigating this array up or down by clicking a button that either navigates upward or downward, which is displayed in the ...

Let's say we have an array that can have a length of 1 to ?? We have a way of navigating this array up or down by clicking a button that either navigates upward or downward, which is displayed in the ...

  1. index array bounds matlab
  2. index outside bounds array c#
  3. index outside bounds array
  4. index out bounds array
  5. index exceeds array bounds
  6. index exceeds array bounds matlab
  7. index exceeds array bounds matlab error
  8. index exceeds array bounds title matlab
  9. index exceeds array bounds matlab meaning
  10. index exceeds array bounds meaning
  11. index exceeds array bounds xlabel
  12. index exceeds array bounds simulink
  13. index exceeds array bounds matlab plot
  14. index out of bounds array c#
  15. index exceeds array bounds parfor
  16. index outside bounds of array sql server
  17. sql index outside bounds array
  18. array index bounds of exception
  19. index outside bounds of array error
  20. array index bounds exception java