Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Collecting data with jQuery from a table
- <table>
- <thead>
- <tr>
- <th></th>
- <th>Name</th>
- <th>Email</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class='checkinput'>
- <input type="checkbox" name="names" value="MD5_HASH"/>
- </td>
- <td>
- John Doe
- </td>
- <td>
- email@mail.com
- </td>
- </tr>
- <!-- etc. -->
- </tbody>
- </table>
- $("tr").click(function() {
- var $checkbox = $(this).find(":checkbox");
- $checkbox.attr('checked', !$checkbox.attr('checked'));
- });
- $("tr").click(function(e) {
- if ($(e.target).is(':checkbox')) return;
- var $checkbox = $(this).find(":checkbox");
- $checkbox.attr('checked', !$checkbox.attr('checked'));
- });
- var emails = [];
- $("table tbody tr:has(input:checkbox:checked)").each(function(){
- emails.push( $('td.email', $(this)).text() );
- });
- $("tr).click(function(e) {
- if (e.target.id==xxx) // if ($('#'+e.target.id).attr('class')=='classssss') ...
- ....
- });
- $(".table tr:gt(0)").each (
- function () {
- alert($('td:eq(2)',$(this)).text());
- }
- );
Add Comment
Please, Sign In to add comment