JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div class="dropdown">
<table id="timer">
<tbody>
<tr>
<td class="headtext">TITLE</td>
<td class="headtext">TITLE</td>
</tr>
</tbody>
</table>
</div>
</body>
CSS
.dropdown {
width: 600px;
padding: 0px;
padding-top:100px;
padding-bottom:150px;
}
table {
border-width: 70px;
border-color: black;
background-color: #DCF5F1;
}
.dropdown {
margin: auto;
}
th {
border: 2px solid black;
}
td {
border: 2px groove black;
}
a {
text-decoration: none;
color:black;
}
a:hover {
color: grey;
text-decoration: underline;
}
table {
width: 600px;
table-layout: fixed;
font-size: 20px;
}
table td {
padding: 20px;
font-weight: bold;
font-family: arial;
}
#timer .endsoon {
color: red;
}
@media screen and (min-width: 1000px) {
[data-title]:hover:after {
/* opacity: 1;
transition: all 0.5s ease 0.5s;
visibility: visible; */
}
[data-title]:after {
/* content: attr(data-title);
background-color: #f4c2sc2; */
/* background-image: url(arr[3]); */ /* The idea is that the value should come from the javascript array at the third place */
/* font-size: 20px;
position: absolute;
padding: 20px 5px 2px 5px;
left: -130px;
top: -35px;
height: 60px;
width: 80px;
white-space: nowrap;
opacity: 0;
z-index: 99999;
visibility: hidden; */
}
[data-title] {
/* position: relative; */
}
}
JavaScript
var arr = [
// Date...................Link..............Title
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'https://www.flaticon.com/svg/static/icons/svg/1011/1011407.svg'], //* I'm trying to figure out how the value in position 3, to be put into the Background-image in the css.
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'https://www.flaticon.com/svg/static/icons/svg/181/181531.svg'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
['Dec 18, 2020 01:00:00', 'TEXT', 'TEXT', 'image.png'],
];
// Remove after 5min
var remAft = 10;
// Get element with ID "timer"
var wrap = document.querySelector('#timer tbody');
// For loop Array "arr"
for (var i = 0; i < arr.length; i++) {
if (checkDate(arr[i][0])) {
// Adds the elements of the table with filled in information
//https://www.w3schools.com/TAgs/tag_body.asp
wrap.innerHTML += '<tr><td background=' + arr[i][3] + '><a href="' + arr[i][1] + '"' + 'data-title="' + '" >' + arr[i][2] + '</a></td><td id="' + 'demo' + (i + 1) + '"></td></tr>'
// OR LIKE THIS
// wrap.innerHTML += '<tr><td style=\"background-image: url(' + arr[i][3] + ')\"><a href="' + arr[i][1] + '"' + 'data-title="' + '" >' + arr[i][2] + '</a></td><td id="' + 'demo' + (i + 1) + '"></td></tr>'
// Invokes the function by passing as arguments Date and ID
new myTimers(arr[i][0], 'demo' + (i + 1));
// NOTE: Your 'data-title' attribute selector doesn't seem to be doing anything here, because you are not...