javascript - How do I link cells interactively with jquery? -
how able link cells create new cell call add global value in snippet. in snippet there 3 chosen rows can chosen @ random user , number of them.
what want able link chosen rows add new cel has overall value captured user.
how link cells depending on ones user chooses. jquery in interactive way not reload page.
i want know how go solve problem.
the code snippet shows visual example after rows chosen user should create new cel next it.
they have linked 3 have global value of new cell...
$(document).ready(function() { $('tbody tr').eq(0).find('td').eq(7).css('background-color', 'green'); $('tbody tr').eq(3).find('td').eq(7).css('background-color', 'green'); $('tbody tr').eq(4).find('td').eq(7).css('background-color', 'green'); });
table, td { border: 1px solid #000; } td { width: 40px; height: 40px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <body> <table> <tbody> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> </body>
i'm guessing want function this:
$('tr').click(function(){ // tr clicked var $tr = $(this); // create new td green background-color var $newtd = $('<td></td>').css('background-color', 'green'); // append new td clicked row $tr.append($newtd); // add empty td other rows $('tr').not($tr).append('<td></td>'); });
Comments
Post a Comment