I'm creating a PivotTable in Javascript to represent a set of favorite links that will be managed through HTML document.
Example
document.getElementById('resultado').innerHTML =[
'<table>',
'<tr>',
'<th>ID</th>',
'<th>RESULTADO</th>',
'</tr>',
'<tr>',
'<td>1</td>',
'<td id="cel1">http://www.br.ask.com</td>',
'</tr>',
'<tr>',
'<td>2</td>',
'<td id="cel1">http://www.google.com</td>',
'</tr>',
'<tr>',
'<td>3</td>',
'<td id="cel3">http://www.yahoo.com</td>',
'</tr>',
'<tr>',
'<td>4</td>',
'<td id="cel4">https://www.bing.com/</td>',
'</tr>',
'<tr>',
'<td>5</td>',
'<td id="cel5">http://www.likata.com/</td>',
'</tr>',
'</table>'
].join('\n');
var text_01 = document.getElementById('cel1').innerHTML;
var text_02 = document.getElementById('cel3').innerHTML;
var conta = 0;
var clic = document.getElementById('cel3');
clic.onclick = function()
{
if(conta == 4) conta = pos();
conta++;
}
pos = function()
{
document.getElementById('cel1').innerHTML = text_02;
document.getElementById('cel3').innerHTML = text_01;
}
table{
width: 100%;
border: thin solid silver;
color: white;
}
th{
background-color: black;
color: white;
}
tr td{
background-color: white;
color: black;
}
<span id="resultado"></span>
Links that get the highest number of clicks go up to the first few lines
Look at Figures 1 and 2 below:
Before
Inthisillustrativeexample,astheuserclickednumeroustimesonLink-"www.yahoo.com" and soon it goes up to the top places. See:
Then
Iwillmakeabriefcomparisontoexemplify.Let'ssee:
Herein.stackoverflowwhereitsays:
"The best answers are positive and go up to the top"
In this same line of thinking, I mention:
"The links that receive the highest number of clicks / visits, go up to the first few lines"
But for the "Link" most accessed appear between the first few lines, you need to create
script
with techniques to improve sorting.
I quote referral on part of the subject :
html-and-javascript-changing-two- elements-of-position-swap
Implementing a list of objects with the option to change their positions in the list
I need to change the value of a column in a table with javascript. How to do?