get the content of cells when selection by column (selectable)
Hello,
my question is quite simple, but I can't manage to make it work properly
I have a table and I want all cells of the table to be "selectable" by using the selectable plugin of jquery UI
here below my table :
<table id=\"selectable\">
<tr> <th class=\"ui-widget-content\"> A </th> <th class=\"ui-widget-content\"> B </th> <th class=\"ui-widget-content\"> C </th> </tr>
<tr> <td class=\"ui-widget-content\"> 1 </td> <td class=\"ui-widget-content\"> 2 </td> <td class=\"ui-widget-content\"> 3 </td> </tr>
<tr> <td class=\"ui-widget-content\"> 10 </td> <td class=\"ui-widget-content\"> 20 </td> <td class=\"ui-widget-content\"> 30 </td> </tr>
<tr> <td class=\"ui-widget-content\"> 100 </td> <td class=\"ui-widget-content\"> 200 </td> <td class=\"ui-widget-content\"> 300 </td> </tr>
</table>
I want to check if I cant get the content of each cell that is "selected" by the mouse, when I select only through one column (not according to rows) :
then the javascript here below :
$(function() {
$(\"#selectable\").selectable({
stop: function(){
var result = $(\"#select-result\").empty();
contenu = $(\".ui-selected\").text();
result.append(contenu);
}
});
});
the result of this I can select with the mouse by column but my script get always the contect of ALL cells and not only the one selected !!
can you please help me ?
if needed below my full script
<?php
print "<!doctype html>
<html lang=\"en\">
<head>
<link rel=\"stylesheet\" href=\"//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css\">";
//<link rel=\"stylesheet\" href=\"/resources/demos/style.css\">
print "<style>
#feedback { font-size: 1.4em; }
#selectable .ui-selecting { background: #FECA40; }
#selectable .ui-selected { background: #F39814; color: white; }
#selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
#selectable td { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
</style>
<script src=\"https://code.jquery.com/jquery-1.12.4.js\"></script>
<script src=\"https://code.jquery.com/ui/1.12.1/jquery-ui.js\"></script>
<script type=\"text/javascript\">
$(function() {
$(\"#selectable\").selectable({
stop: function(){
var result = $(\"#select-result\").empty();
contenu = $(\".ui-selected\").text();
result.append(contenu);
}
});
});
</script>
</head>
<body>
<div class=\"demo\">
<p id=\"feedback\">
You've selected: <span id=\"select-result\">none</span>.
</p>
<table id=\"selectable\">
<tr> <th class=\"ui-widget-content\"> A </th> <th class=\"ui-widget-content\"> B </th> <th class=\"ui-widget-content\"> C </th> </tr>
<tr> <td class=\"ui-widget-content\"> 1 </td> <td class=\"ui-widget-content\"> 2 </td> <td class=\"ui-widget-content\"> 3 </td> </tr>
<tr> <td class=\"ui-widget-content\"> 10 </td> <td class=\"ui-widget-content\"> 20 </td> <td class=\"ui-widget-content\"> 30 </td> </tr>
<tr> <td class=\"ui-widget-content\"> 100 </td> <td class=\"ui-widget-content\"> 200 </td> <td class=\"ui-widget-content\"> 300 </td> </tr>
</table>
</body>
</html>";
?>