Friday, 15 February 2013

javascript - jQuery - Color table rows when checkbox is checked and remove when not -



javascript - jQuery - Color table rows when checkbox is checked and remove when not -

i'm little stuck, can't head around problem. have setup jquery identifies values in radio inputs, align values within table. start doing filtering on table.

i want next 3 things happen:

whenever click on filter , cell has same value, it's row gets highlighted whenever check alternative off, gets removed if page loads , alternative checked, row gets highlighted on load

jquery code:

$(function () { // on alter of radio buttons $('input').on('change', function () { var filter = $('input:checkbox[name=filter]:checked').val(); // edit rows $(".gamestatus").filter(function () { homecoming $(this).text() == filter; }).parent('tr').addclass('filtered'); }); });

jsfiddle: http://jsfiddle.net/darcyvoutt/8xgd51mg/

$(function () { var filters = []; var edit_rows = function () { filters = []; $('input:checkbox[name=filter]:checked').each(function () { filters.push(this.value); }); // edit rows $(".gamestatus").each(function () { $(this).parent('tr') .toggleclass('filtered', filters.indexof($(this).text()) > -1 ); }); } edit_rows(); // on alter of radio buttons $('input').on('change', edit_rows); });

jsfiddle

edit: added functionality gets invoked on page load

javascript jquery html css

No comments:

Post a Comment