venkat

venkat

  • NA
  • 138
  • 51.7k

how to unselect the table column using javascript

Aug 1 2017 2:08 AM
hi all,
i wrote code for select vertical column . what i did is when ever we click on column it will select entire column and we can copy text. now i need to do unselect  option . please help me for unselect entire column.
below is my code.
 
<textarea rows="1" cols="20" id="website" style="display: none;" />
<button data-copytarget="#website" id="btncopy" style="display: none;">copy</button>
 
 
function Copytext(obj) {
//debugger;
document.getElementById("btncopy").style.display = "";
document.body.addEventListener('click', copy, true);
document.getElementById("btncopy").click();
document.body.removeEventListener('click', copy, true);
}
function copy(e) {
// debugger;
var table = $("#ValidationStatusTable");
var accountNos = "";
var tbl2 = table.find("tr").each(function (i) {
if ($(this)[0].rowIndex != 0 && $(this)[0].rowIndex != table.find("tr").length-1) {
$(this)[0].cells[0].bgColor = "gray";
accountNos = accountNos + $(this)[0].cells[0].innerText + "\n";
}
})
try {
document.getElementById("website").style.display = "";
document.getElementById("website").innerHTML = accountNos;
t = e.target,
c = t.dataset.copytarget,
inp = (c ? document.querySelector(c) : null);
document.querySelector(c).select();
document.execCommand('copy');
inp.blur();
document.getElementById("website").style.display = "none";
document.getElementById("btncopy").style.display = "none";
}
catch (err) {
alert('please press Ctrl/Cmd+C to copy');
}
}
 

Answers (2)