Tagged: Accordion Sort, Easy Sider Arrows, mobile, table
I have three items that I’ve demonstrated on the page in the private area:
1) Tables don’t work well on mobile. the headers stack first and then the data cells. Can this be fixed?
2) On our French website, the accordion sort option isn’t working. It does on the English website.
3) On mobile, the arrows on the easy slider sometimes cover the words, Can this be improved? If not, I can remove the arrows.
Hey beverlystone,
To restructure the table for mobile view from this:
to this:
I added this javascript to your WP Code plugin as a new snippet, and in the top right corner I used the javascript snippet as the code type:
and then saved.
document.addEventListener("DOMContentLoaded", function() {
function restructureTableForMobile() {
var screenWidth = window.innerWidth;
var tables = document.querySelectorAll('tbody');
if (screenWidth <= 767 && tables.length > 0) {
tables.forEach(function(table) {
var rows = table.querySelectorAll('tr');
var newTableStructure = document.createDocumentFragment();
var columns = rows[0].children.length;
for (let colIndex = 0; colIndex < columns; colIndex++) {
var newRow = document.createElement('tr');
rows.forEach(function(row, rowIndex) {
var cell = row.children[colIndex].cloneNode(true);
newRow.appendChild(cell);
});
newTableStructure.appendChild(newRow);
}
table.innerHTML = '';
table.appendChild(newTableStructure);
});
}
}
restructureTableForMobile();
window.addEventListener('resize', restructureTableForMobile);
});
This will also work for multiple tables on the page, so I added another table to demonstrate, please check.
Best regards,
Mike
This works great for the tables! Thank you.
Should I open separate threads for the other two issues?