jquery - Using multiple colors for highlighting -
i have example code highlight specific cells of table. there way switch colors or use multiple colors @ same time?
i need achieve 2 things here. 1) i'd able set color of parameter groups (or parameters individually) color on front-end before click them. 5 colors enough. 2)it not important parameter goes color. colors can assigned randomly. reedited question make clearer.
here fiddle page project: http://jsfiddle.net/max33/kjcyu3yb/
$('.selector').each(function() { $(this).on('click', check); }); $('.all').each(function() { $(this).on('click', all); }); function all(event) { if($(this).is(':checked')){ $("input:checkbox:not(:checked)",$(this).parents('form')).not(this).prop("checked","checked"); } else { $("input:checkbox(:checked)",$(this).parents('form')).not(this).prop("checked",""); } //$('.selector').prop("checked", this.name === "selectall"); check(event); } function check(event) { var checked = $(".selector:checked").map(function () { return this.name }).get() $('td').removeclass("highlight").filter(function () { return $.inarray($(this).text(), checked) >= 0 }).addclass("highlight") if ($(this).is(".selector")) $('.all').not(this).prop("checked", false) }
you can use different classes each form element. have used highlight-x
x. after adding general highlight
class selected elements, adding class x
. can remove classes @ once using removeclass
no parameters. remove of item's classes. check this fiddle. select first form. see x
highlighted using red
. if doesn't go requirement let me know.
Comments
Post a Comment