table - Multi-select and deselect of columns - jquery -


i want write content of 1 or more columns array. should possible deselect column. use following code address column, don't know how content.

$("td").click(function () {     var columnno = $(this).index();     $(this).closest("table")         .find("tr td:nth-child(" + (columnno + 1) + ")")         .css("color", "red"); }); 

example in jsfiddle

any appreciated

thank you!

try this:

$(document).ready(function(){     var text = []; $("td").click(function () {     var columnno = $(this).index();     $(this).closest("table")         .find("tr td:nth-child(" + (columnno + 1) + ")")         .toggleclass("selected");     var val = $(this).closest("table")         .find("tr td:nth-child(" + (columnno + 1) + ")").text(); // column text     if($(this).hasclass( "selected" )){ //to check whether user selected or not         if($.inarray(val,text)<0){ //check value exists in array             text.push(val);         }     }else{         text.splice($.inarray(val, text),1); //if user deselect remove column text array     }     console.log(text); }); }); 

demo


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -