Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML table, when i ctrl+click, the border of the cell appears?

I have put an onclick listener on the row element n a table, but when i do click on a row (whilst pressing ctrl), a border appears around the cell i clicked on.

Is there anyway to prevent this?

like image 787
Tom Avatar asked Feb 21 '11 15:02

Tom


People also ask

How do I select a cell in a HTML table?

To select data in the second column of the following HTML table, hold down Ctrl and click the Example 2 cell and drag down to Four. Once selected press Ctrl + C to copy the data, and then Ctrl + V to paste it elsewhere.

What is table border in HTML?

Table Border in HTML is used to display a border around the table contents. This can be set around the table by specifying values like 0 for no border is showing around the table cells, whereas value 1 is set to display a border around the table cells.


2 Answers

I found this question looking for the solution myself. I thought I'd share what I found elsewhere that seems to do the trick. Note - this is a firefox issue.

Solution is to add "-moz-user-select: none;" for table elements that you want to disable this behavior.

found at http://support.mozilla.org/en-US/questions/763547

like image 74
stu Avatar answered Oct 14 '22 18:10

stu


I think you're running into something that Firefox does by default for tables.

This snippet that I found somewhere works for me:

$('table').mousedown(function (event) {
    if (event.ctrlKey) {
        event.preventDefault();
    }
});
like image 30
no.good.at.coding Avatar answered Oct 14 '22 19:10

no.good.at.coding