admin管理员组

文章数量:1278918

I have a table on my web page that have checkboxes on them. I have jquery code that allows me to shift click to check multiple rows for editing/removal. But when I shift click to select a range all of the text inside the range gets highlighted.

Is there any way using jquery or css to stop the text from being highlighted?

--EDIT--

    HTML code
...
<tbody>
  <tr>
    <td>
      <input type="checkbox">
    </td>
    <td>
      <div class="cam_ip">192.168.200.78</div>
    </td>
  </tr>
  <tr>
    <td>
      <input type="checkbox">
    </td>
    <td>
      <div class="cam_ip">192.168.200.250</div>
    </td>
  </tr>
</tbody>

There can be x amount of rows. The jquery works when I click a row, that row is marked as an anchor, then when I shift click on another row it is marked as anchorrange, then a function is called which will loop through each row inside the range making it checked. The side effect of using e.shiftClick(); is that all the text within the range gets highlighted. I need to stop this side effect.

I have a table on my web page that have checkboxes on them. I have jquery code that allows me to shift click to check multiple rows for editing/removal. But when I shift click to select a range all of the text inside the range gets highlighted.

Is there any way using jquery or css to stop the text from being highlighted?

--EDIT--

    HTML code
...
<tbody>
  <tr>
    <td>
      <input type="checkbox">
    </td>
    <td>
      <div class="cam_ip">192.168.200.78</div>
    </td>
  </tr>
  <tr>
    <td>
      <input type="checkbox">
    </td>
    <td>
      <div class="cam_ip">192.168.200.250</div>
    </td>
  </tr>
</tbody>

There can be x amount of rows. The jquery works when I click a row, that row is marked as an anchor, then when I shift click on another row it is marked as anchorrange, then a function is called which will loop through each row inside the range making it checked. The side effect of using e.shiftClick(); is that all the text within the range gets highlighted. I need to stop this side effect.

Share Improve this question edited Apr 20, 2012 at 14:11 DarylF asked Apr 20, 2012 at 13:50 DarylFDarylF 7263 gold badges9 silver badges24 bronze badges 1
  • 1 You gotta show us your code + which plugin you use. – gdoron Commented Apr 20, 2012 at 13:52
Add a ment  | 

1 Answer 1

Reset to default 10

CSS version

user-select: none;
-webkit-user-select: none;
-moz-user-select: none;

also a possible related question to How to disable text selection highlighting using CSS?

Year later edit (integrating from ment):

Colleague pointed this out Is there a way to make text unselectable on an HTML page? - use unselectable="on" on whatever you want not selectable

本文标签: javascriptStop a shift click from highlighting textStack Overflow