Is there a way to extract the first cell from a row when a user hovers over it and then clicks a specific key combination? (considering using jQuery) I have a table set up similarly where placing the mouse over a tr and pressing ctrl+c will copy the ID to the clipboard. Thank you! Update: See the code below that worked.
<table>
<tr>
<td>ID</td>
<td>Text1</td>
<td>Text2</td>
<td>Text3</td>
</tr>
<tr>
<td id="my_id">1</td>
<td>Example1</td>
<td>Example1</td>
<td>Example1</td>
</tr>
<tr>
<td id="my_id">2</td>
<td>Example2</td>
<td>Example2</td>
<td>Example2</td>
</tr>
<tr>
<td id="my_id">3</td>
<td>Example3</td>
<td>Example3</td>
<td>Example3</td>
</tr>
</table>
$(document).ready(function()
{
var ctrlDown = false;
var ctrlKey = 17, cKey = 67;
var id = "";
$(document).keydown(function(e) {
if (e.keyCode == ctrlKey) ctrlDown = true;
});
$("tr").mouseover(function(){
id = $(this).find("#my_id").html();
});
$("tr").mouseout(function(){
id = "";
});
$(document).keydown(function(e)
{
if (ctrlDown && e.keyCode == cKey) {
if (id != "") {
window.prompt("Copy to clipboard: Ctrl+C, Enter", id);
ctrlDown = false;
}
}
});
});