JQuery table cell selection script - javascript

I am a student, new to programming and want to learn Javascript by trying stuff. I am doing an exercise which requires me to highlight table cells on mouse drag. I got it to work but I am having problems figuring out how to highlight cells by dragging any direction (not just from X to Y direction). The code below shows how it works from X to Y direction; I want it to do the same when user drags the mouse from Y to X direction.
For example, consider A, B, C, D, G, H and I as table cells.
A B C
D E F
G H I
Dragging the mouse along the diagonal from A to E selects cells A,B,D & E. I want I, H, F, E to be selected on mouse drag from I to E.
Here is the working code:
$(function () {
var isMouseDown = false,
isHighlighted;
var mouseDownRowX = 0;
var mouseDownRowY = 0;
$("#assayPlateTable2 td.dragShadow")
.click(function () {
$("#assayPlateTable2 td").each(function () {
var currClass = $(this).attr('class');
if(currClass == 'dragShadow') {
$(this).css('backgroundColor', 'none');
}
});
var currClass = $(this).attr('class');
if(currClass == 'dragShadow') {
$(this).css('backgroundColor', '#dff0de');
}
currRow = $(this).parent().parent().children().index($(this).parent());
})
.mousedown(function () {
isMouseDown = true;
mouseDownRowX = $(this).parent().parent().children().index($(this).parent());
mouseDownRowY = $(this).parent().children().index($(this));
return false; // prevent text selection
})
.mouseover(function () {
//alert('mouse over' + isMouseDown);
if (isMouseDown) {
currRow = $(this).parent().parent().children().index($(this).parent());
currCol = $(this).parent().children().index($(this));
//var currRow = 1;
//var currCol = 1;
$("#assayPlateTable2 td").each(function () {
_mouseDownRowX = $(this).parent().parent().children().index($(this).parent());
_mouseDownRowY = $(this).parent().children().index($(this));
if(_mouseDownRowX >=
mouseDownRowX && _mouseDownRowX <= currRow && _mouseDownRowY
>= mouseDownRowY && _mouseDownRowY <= currCol) {
var currClass = $(this).attr('class');
if(currClass == 'dragShadow') {
$(this).css('backgroundColor', '#dff0de');
}
//alert("setting==>" + currRow + "," + currCol);
} else {
var currClass = $(this).attr('class');
if(currClass == 'dragShadow') {
$(this).css('backgroundColor', 'none');
}
}
});
for(var i = mouseDownRowX; i < _mouseDownRowX; i++) {
for(var j = mouseDownRowY; j < _mouseDownRowY; j++) {
}
}
//$(this).parent().toggleClass("highlighted", isHighlighted);
//$(this).parent().css('backgroundColor', '#dff0de');
}
})
.bind("selectstart", function () {
return false;
})
$(document)
.mouseup(function () {
isMouseDown = false;
});
});
</script>
HTML:
<table cellpadding="0" cellspacing="0" id="assayPlateTable2">
<tr>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
</tr>
<tr>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
<td class="dragShadow"> </td>
</tr>
<tr>...</tr> and so on
</table>

For more user friendly in selecting calendar cells, I recommend this one eHighLight Plugin. A very easy and tiny plugin for document element high lighting

Related

How to calculate number of items on the basis table td?

I using this code for calculating number of times a vehicle is added. The code is not returning the correct value. I want to calculate how many times the same vehicle is selected in each row of the table.
function calculateNumberOfVehicles(vehicleId) {
var returnValue = 0;
var table = $("#selected_students");
table.find('tr').each(function(i, el) {
var counter = 0;
var rowId = $(this).attr('id');
var actualId = rowId.substr(rowId.indexOf("_") + 1).trim();
var addedVehicleId = $("#lockedVehicleId_" + actualId).text();
if (parseInt(vehicleId) == parseInt(addedVehicleId)) {
counter++
returnValue = counter;
}
});
return returnValue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tbody id="selected_students">
<tr id="row_5ae958a4bb2c561a10003dcc">
<td>Adam Zaffar</td>
<td>L.K.G</td>
<td>Male</td>
<td id="lockedRoute_5ae958a4bb2c561a10003dcc">Karan Nagar</td>
<td id="lockedStop_5ae958a4bb2c561a10003dcc">Lal chowk</td>
<td id="lockedVehicle_5ae958a4bb2c561a10003dcc">JK 123</td>
<td class="delete_row_dynamic"><button relation="5b962874d2ccda10ac003702" title="Delete" id="5ae958a4bb2c561a10003dcc" class="btn btn-danger table_btn btn-outline btn-sm deleteBtn"><i class="fa fa-trash"></i></button></td>
<td id="lockedRouteId_5ae958a4bb2c561a10003dcc" class="hide">5b83dc30d2ccda0b60005c0f</td>
<td id="lockedStopId_5ae958a4bb2c561a10003dcc" class="hide">b930e948-202b-697c-5615-58939cff2ac2</td>
<td id="lockedVehicleId_5ae958a4bb2c561a10003dcc" class="hide">5b962874d2ccda10ac003702</td>
<td id="lockedVehicleIdSeats_5ae958a4bb2c561a10003dcc" class="hide">3</td>
</tr>
<tr id="row_5b17cc27bb2c5633f400197c">
<td>Adnan Mir</td>
<td>L.K.G</td>
<td>Male</td>
<td id="lockedRoute_5b17cc27bb2c5633f400197c">New Jersey City</td>
<td id="lockedStop_5b17cc27bb2c5633f400197c">City Center</td>
<td id="lockedVehicle_5b17cc27bb2c5633f400197c">JK 123</td>
<td class="delete_row_dynamic"><button relation="5b962874d2ccda10ac003702" title="Delete" id="5b17cc27bb2c5633f400197c" class="btn btn-danger table_btn btn-outline btn-sm deleteBtn"><i class="fa fa-trash"></i></button></td>
<td id="lockedRouteId_5b17cc27bb2c5633f400197c" class="hide">5b7fb426d2ccda11fc005185</td>
<td id="lockedStopId_5b17cc27bb2c5633f400197c" class="hide">aa61d076-30c1-31ff-c245-968178042e46</td>
<td id="lockedVehicleId_5b17cc27bb2c5633f400197c" class="hide">5b962874d2ccda10ac003702</td>
<td id="lockedVehicleIdSeats_5b17cc27bb2c5633f400197c" class="hide">3</td>
</tr>
</tbody>
</table>
Try this
var result = calculateNumberOfVehicles('5b962874d2ccda10ac003702');
console.log(result); // This will output the number in console.
function calculateNumberOfVehicles(vehicleId) {
var returnValue = 0;
var table = $("#selected_students");
var counter = 0;
table.find('tr').each(function(i, el) {
var rowId = $(this).attr('id');
var actualId = rowId.substr(rowId.indexOf("_") + 1).trim();
var addedVehicleId = $("#lockedVehicleId_" + actualId).text();
if (parseInt(vehicleId) == parseInt(addedVehicleId)) {
counter++
returnValue = counter;
}
});
return returnValue;
}
function calculateNumberOfVehicles(vehicleId) {
var returnValue = 0;
var table = $("#selected_students");
table.find('tr').each(function (i, el) {
var rowId = $(this).attr('id');
var actualId = rowId.substr(rowId.indexOf("_") + 1).trim();
var addedVehicleId = $("#lockedVehicleId_" + actualId).text();
if (parseInt(vehicleId) == parseInt(addedVehicleId)) {
returnValue++;
}
});
return returnValue;
}

Colorizing table rows based on high/ low value with Javascript or Jquery

I am trying to create a function that will colorize the contents of the table based on the values of the row.
I am able to get the data from each row into an array and save the low and high values to a variable. How can I add a class low or high to the low and high values in each row?
In each tr I only want to compare the 1st,2nd,and 3rd position as the zero position is the index.
function showRows(s) {
var t = s.options[s.selectedIndex].text;
var rows = document.getElementById('mytab').getElementsByTagName('tr'),
i = 0,
r, c;
while (r = rows[i++]) {
if (t == 'All') {
r.style.display = ''
} else {
c = r.getElementsByTagName('td')[0].firstChild.nodeValue;
sxval = r.getElementsByTagName('td')[1].firstChild.nodeValue;
fcval = r.getElementsByTagName('td')[2].firstChild.nodeValue;
sgval = r.getElementsByTagName('td')[3].firstChild.nodeValue;
unval = r.getElementsByTagName('td')[4].firstChild.nodeValue;
array = [sxval, fcval, sgval, unval]
var low = Math.min(...array)
var high = Math.max(...array)
console.log("lowest" + " " + low)
console.log("highest" + " " + high)
console.log(c)
console.log(t)
r.style.display = parseInt(c) == parseInt(t) ? '' : 'none';
}
}
}
<body>
<table align="center" border="1" width="50%" cellspacing="0" cellpadding="4">
<tr>
<th>
<select name="mylist" onchange="showRows(this)">
<option value="m1">All</option>
<option value="m2">4</option>
<option value="m3">4.5</option>
<option value="m4">5</option>
</select>
</th>
</tr>
<br>
<table id="mytab" align="center" border="1" width="50%" cellspacing="0" cellpadding="4">
<tr class="content">
<td class="cj-has-text-centered contentcheck">
4 </td>
<td class="cj-has-text-centered">
50 </td>
<td class="cj-has-text-centered">
100 </td>
<td class="cj-has-text-centered">
200 </td>
<td class="cj-has-text-centered">
300 </td>
</tr>
<tr class="content">
<td class="cj-has-text-centered contentcheck">
4.5 </td>
<td class="cj-has-text-centered">
50 </td>
<td class="cj-has-text-centered">
100 </td>
<td class="cj-has-text-centered">
200 </td>
<td class="cj-has-text-centered">
300 </td>
</tr>
<tr class="content">
<td class="cj-has-text-centered contentcheck">
5 </td>
<td class="cj-has-text-centered">
50 </td>
<td class="cj-has-text-centered">
100 </td>
<td class="cj-has-text-centered">
200 </td>
<td class="cj-has-text-centered">
300 </td>
</tr>
</table>
You can use Jquery to do this. Here is the sample. Hope to help, my friend :))
<style>
.highest{
background-color:blue;
}
.lowest{
background-color:red;
}
</style>
function showRows(s) {
var t = s.options[s.selectedIndex].text;
var rows = document.getElementById('mytab').getElementsByTagName('tr'),
i = 0,
r, c;
while (r = rows[i++]) {
if (t == 'All') {
r.style.display = ''
} else {
c = r.getElementsByTagName('td')[0].firstChild.nodeValue;
sxval = r.getElementsByTagName('td')[1].firstChild.nodeValue;
fcval = r.getElementsByTagName('td')[2].firstChild.nodeValue;
sgval = r.getElementsByTagName('td')[3].firstChild.nodeValue;
unval = r.getElementsByTagName('td')[4].firstChild.nodeValue;
array = [sxval, fcval, sgval, unval]
var low = Math.min(...array)
var high = Math.max(...array)
console.log("lowest" + " " + low)
console.log("highest" + " " + high)
console.log(c)
console.log(t)
r.style.display = parseInt(c) == parseInt(t) ? '' : 'none';
//Skip the first column, use :not(:first-child)
$('tr').each(function(){
var vals = $('td:not(:first-child)',this).map(function () {
return parseInt($(this).text(), 10) ? parseInt($(this).text(), 10) : null;
}).get();
// then find their minimum
var min = Math.min.apply(Math, vals);
var max = Math.max.apply(Math, vals);
// tag any cell matching the min and max value
$('td', this).filter(function () {
return parseInt($(this).text(), 10) === min;
}).addClass('highest');
$('td', this).filter(function () {
return parseInt($(this).text(), 10) === max;
}).addClass('lowest');
});
}
}
};

check if the cell of a table has a certain color

the cells of the table get for a short moment a red color . the cells are selected by random numbers.
when a cell has a red color then the user shall click the cell.
if he clicks the cell when the cell is still red then he get a point.
that is the idea. but it not works. when i click the cell nothing happens.
<!DOCTYPE html>
<html>
<head>
<style>
td{font-size:40px; padding:4px 10px;}
</style>
<script>
var blinkColors = new Array('red' );
var zw= new Array();
var blinkColor = 0;
var iterator = 0;
var hit=0;
for (var i = 0 ;i<10;i++){
zw[i]=Math.floor((Math.random() *8) + 1);
}
var myBlink = setInterval(function() {
doBlink();
}, 400);
function doBlink() {
var blinkCell = document.getElementById('blinker' +zw[iterator] );
blinkCell.style.backgroundColor = blinkColors[blinkColor];
blinkColor++;
if (blinkColor == blinkColors.length+1) {
blinkColor = 0;
blinkCell.style.backgroundColor = "transparent";
iterator++;
if (iterator == zw.length) {
alert("You hit. " + hit);
clearInterval(myBlink);
} else {
doBlink(zw[iterator]);
}
}
function hitColor(blink){
if (document.getElementById('blink').style.backgroundColor=="red")
hit++;
}
</script>
</head>
<body>
<table border="1">
<tr>
<td id="blinker0"onclick="melden(blinker6")> A </td><td id="blinker1"> B </td><td id = "blinker2"> C </td>
</tr>
<tr>
<td id="blinker3"onclick="melden(blinker6")> D </td><td id="blinker4"> E </td><td id = "blinker5"> F </td>
</tr>
<tr>
<td id="blinker6" onclick="melden(blinker6)" > G </td><td id="blinker7"> H </td><td id = "blinker8"> I </td>
</tr>
</table>
<br>
</body>
</html>
Pull the second if block out of the first one:
if (blinkColor == blinkColors.length+1) {
blinkColor = 0;
blinkCell.style.backgroundColor = "transparent";
iterator++;
}
if (iterator == zw.length) {
alert("You hit. " + hit);
clearInterval(myBlink);
} else {
doBlink(zw[iterator]);
}

How to filter Table row with multiple condition .ie on checkbox selection show respected row. each checkbox represent Column and row value

I have a table with some dynamic data, and columns as Name,Location, Salary. Problem i am facing in Step 2 i.e multiple condition check. Heres the step by step code.
JS Fiddle Demo
Step 1-
Auto generate Filters i.e dynamically add Checkboxes, depend on table row values
autoFilterItem("filterDiv");
Above function generate dynamic checkboxes, logic is it loop over table, read values row by row and return unique value array and generate checkbox respectively, currently am doing for 2 cols having class loc,sal.
Step 2-
Checkbox change event, depend on status (checked/unchekced) table rows will be hide/show .
The problem i am facing is, if user checked 100 ( class as sal), and Kerala ( class as loc) is unchecked then row having kerala should be hide.
For hide and show am adding/removing class .hideRow
///STEP TWO
// On any checkbox clicked returns desired out
$("body").on('change', '.chk', function () {
var arrObj = [],
arrCheckedValueCLass = [];
var objCheckedData = {};
$("#filterDiv .chk").each(function (index, val) {
var sf = $(this);
if (sf.is(":checked")) {
var sf = $(this);
arrObj.push({
dataValue: $(sf).attr('data-value'),
dataClass: $(sf).attr('data-class')
});
}
});
var self = $(this);
var getClassName = self.attr("data-class");
var matchTextValue = $.trim(self.attr("data-value"));
if (self.is(":checked")) {
if (matchTextValue == "All") {
$(".chk").prop('checked', true);
}
$("." + getClassName).each(function () {
var innerSelf = $(this);
var gVal = $.trim(innerSelf.html());
if (matchTextValue == "All") {
innerSelf.closest("tr").removeClass("hideRow");
} else {
if (matchTextValue === gVal) {
console.log("checked and matchTextValue");
var i = 0,
lg = arrObj.length;
var flagSet = false;
for (i; i < lg; ++i) {
var objValue = arrObj[i].dataValue;
var objClass = arrObj[i].dataClass;
if (getClassName != objClass) {
var prevDataCheck = $.trim(innerSelf.closest("tr").find("." + objClass).html());
if (prevDataCheck == objValue) {
flagSet = true;
return true;
}
}
}
if (!flagSet) {
innerSelf.closest("tr").removeClass("hideRow");
innerSelf.closest("tr").addClass(getClassName + "_X");
}
}
}
});
} else {
if (matchTextValue == "All") {
$(".chk").prop('checked', false);
}
$("." + getClassName).each(function () {
var innerSelf = $(this);
var gVal = $.trim(innerSelf.html());
if (matchTextValue === gVal) {
innerSelf.closest("tr").addClass("hideRow");
innerSelf.closest("tr").removeClass(getClassName + "_X");
}
});
}
});
<div id="filterDiv"></div>
<button>Click</button>
<br>
<div id="tableContainer">
<table id="myTable">
<thead>
<tr>
<th data-name='name'>Name</th>
<th data-loc='Location'>Location</th>
<th data-sal='salary'>Salary</th>
<th data-sts='Active'>Active</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name">James</td>
<td class="loc">Mumbai</td>
<td class="sal">500</td>
<td class="sts">Yes</td>
</tr>
<tr>
<td class="name">Joseph</td>
<td class="loc">Kerala</td>
<td class="sal">100</td>
<td class="sts">No</td>
</tr>
<tr>
<td class="name">Jack</td>
<td class="loc">Delhi</td>
<td class="sal">500</td>
<td class="sts">Yes</td>
</tr>
<tr>
<td class="name">Andrea</td>
<td class="loc">Mumbai</td>
<td class="sal">1000</td>
<td class="sts">No</td>
</tr>
<tr>
<td class="name">David</td>
<td class="loc">Delhi</td>
<td class="sal">100</td>
<td class="sts">No</td>
</tr>
<tr>
<td class="name">David</td>
<td class="loc">Delhi</td>
<td class="sal">99900</td>
<td class="sts">No</td>
</tr>
</tbody>
</table>
</div>
I have created the fiddle from the things that you noted and able to produce the result( that is, if user checked 100 ( class as sal), and Kerala ( class as loc) is unchecked then row having kerala should be hide.)
I do not how efficient the solution is.There may be more efficient way to acheive that but anyway below is the js code.
$(document).ready(function () {
//STEP ONE STARTS
// This function generate checkbox from table data, which will be used for filteration
autoFilterItem("filterDiv");
function autoFilterItem(idOfHolderDiv) {
$("#" + idOfHolderDiv).empty();
var arr1 = [];
$(".sal").each(function () {
arr1.push($.trim($(this).html()));
});
var arrNew = unique(arr1).sort(function (a, b) {
return a - b
});
$.each(arrNew, function (i, val) {
$("<input/>", {
"type": "checkbox",
"class": "chk",
"data-class": "sal",
"data-value": val,
"id": "chk" + val,
"checked": "checked"
}).appendTo("#" + idOfHolderDiv).wrap("<div></div>").after(val);
});
$("#" + idOfHolderDiv).append("<hr>");
var arr2 = [];
$(".loc").each(function () {
arr2.push($.trim($(this).html()));
});
var arr2New = unique(arr2).sort();
$.each(arr2New, function (i, val) {
$("<input/>", {
"type": "checkbox",
"class": "chk",
"data-class": "loc",
"data-value": val,
"id": "chk" + val,
"checked": "checked"
}).appendTo("#" + idOfHolderDiv).wrap("<div></div>").after(val);
});
$("#" + idOfHolderDiv).append("<hr>");
function unique(array) {
return $.grep(array, function (el, index) {
return index == $.inArray(el, array);
});
}
}
// STEP ONE ENDS
///STEP TWO
// On any checkbox clicked returns desired out
var selectedSalaryArr = [];
var selectedLocationArr = [];
$("body").on('change', '.chk', function () {
var selectedVal = $(this).attr('data-value');
$('#filterDiv div').each(function () {
var checkedval = $(this).find('input.chk').attr('data-value');
var isChecked = $(this).find('input.chk').is(':checked');
var dataClass = $(this).find('input.chk').attr('data-class');
if (selectedVal === checkedval) {
if (dataClass === 'sal') {
var isExists = $.inArray(checkedval, selectedSalaryArr);
if (isExists === -1) {
selectedSalaryArr.push(checkedval);
} else {
selectedSalaryArr.splice($.inArray(checkedval, selectedSalaryArr), 1);
}
} else {
var isExists = $.inArray(checkedval, selectedLocationArr);
if (isExists === -1) {
selectedLocationArr.push(checkedval);
} else {
selectedLocationArr.splice($.inArray(checkedval, selectedLocationArr), 1);
}
}
}
});
$('#myTable tbody tr').each(function () {
var currentSalary = $(this).find('.sal').text();
var currentLocation = $(this).find('.loc').text();
var matchedSalaryValueExists = $.inArray(currentSalary, selectedSalaryArr);
var matchedLocationValueExists = $.inArray(currentLocation, selectedLocationArr);
if (selectedSalaryArr.length > 0 && selectedLocationArr.length > 0) {
if (matchedSalaryValueExists !== -1 && matchedLocationValueExists !== -1) {
if (!($(this).hasClass('hiderow'))) {
$(this).addClass('hiderow');
}
} else {
if ($(this).hasClass('hiderow')) {
$(this).removeClass('hiderow');
$(this).show();
}
}
}
else {
if (matchedSalaryValueExists !== -1 || matchedLocationValueExists !== -1) {
if (!($(this).hasClass('hiderow'))) {
$(this).addClass('hiderow');
}
} else {
if ($(this).hasClass('hiderow')) {
$(this).removeClass('hiderow');
$(this).show();
}
}
}
});
$('#myTable tbody tr.hiderow').hide();
});
});
Below is the jsfiddle link:
https://jsfiddle.net/shrawanlakhe/v8gyde77/

Javascript double click text transform into textbox

What is the javascipt code that will edit a text on double click. The process is I have a text and if I double click it, a text box will appear, and if I press enter the word will change depends on what you've type.
Sample
This is sample text. $nbsp;$nbsp; --> if I double click it a textbox will appear.
<input type="text" value="This is sample text." name="" />
Sorry for asking this. I am a newbie in javascript
Here is a great example.
I'm going to paste in the script from that example so that it's preserved in case that link goes away, but you should follow the link -- the article does a great job of breaking the script down line by line and explaining what it does. A great learning opportunity for javascript.
var editing = false;
if (document.getElementById && document.createElement) {
var butt = document.createElement('BUTTON');
var buttext = document.createTextNode('Ready!');
butt.appendChild(buttext);
butt.onclick = saveEdit;
}
function catchIt(e) {
if (editing) return;
if (!document.getElementById || !document.createElement) return;
if (!e) var obj = window.event.srcElement;
else var obj = e.target;
while (obj.nodeType != 1) {
obj = obj.parentNode;
}
if (obj.tagName == 'TEXTAREA' || obj.tagName == 'A') return;
while (obj.nodeName != 'P' && obj.nodeName != 'HTML') {
obj = obj.parentNode;
}
if (obj.nodeName == 'HTML') return;
var x = obj.innerHTML;
var y = document.createElement('TEXTAREA');
var z = obj.parentNode;
z.insertBefore(y,obj);
z.insertBefore(butt,obj);
z.removeChild(obj);
y.value = x;
y.focus();
editing = true;
}
function saveEdit() {
var area = document.getElementsByTagName('TEXTAREA')[0];
var y = document.createElement('P');
var z = area.parentNode;
y.innerHTML = area.value;
z.insertBefore(y,area);
z.removeChild(area);
z.removeChild(document.getElementsByTagName('button')[0]);
editing = false;
}
document.onclick = catchIt;
I wanted to know how it works as I have seen it on many websites. And I build it using jQuery
$(document).dblclick(function(event) {
var id = event.target.id; //id
// var id = $(this).attr('id');
if (id == "") {
console.log("nope");
} else {
id = "#" + id + "";
console.log(typeof(id)); //concatenated with #
text = $(id).text().trim();
console.log(text); //asscociated text
$(id).html('<textarea name="" id="tex" cols="10" rows="1" onkeypress="myFunction(event)">' + text + '</textarea>');
// alert(id);
}
})
function myFunction(event) {
var x = event.code;
var id = $(this).attr('id');
parentId = event.path[1].id;
parentId = "#" + parentId + "";
if (x == 'Enter') {
name = $('#tex').val();
$(parentId).text(name);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container mt-3">
<h2>Striped Rows</h2>
<p>The .table-striped class adds zebra-stripes to a table:</p>
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td id="name1" class="name">
john
</td>
<td id="sirname1">Doe</td>
<td id="email1">john#example.chdm som</td>
</tr>
<tr>
<td id="name2" class="name">Mary</td>
<td id="sirname2">Moe</td>
<td id="email2">mary#example.com</td>
</tr>
<tr>
<td id="name3" class="name">July</td>
<td id="sirname3">Dooley</td>
<td id="email3">july#example.com</td>
</tr>
</tbody>
</table>
</div>

Categories