I'd like to scroll to a certain row in my HTML table, which contains dates in the format of
Nov-17-2021
Currently, I have this date.js function which gets today's date and inputs it in a <span>
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
const d = new Date();
var today = new Date();
var date = today.getDate() + '-' + monthNames[d.getMonth()] + '-' + today.getFullYear();
document.getElementById("date").innerHTML = date;
I found that I can use JQuery to scroll easily to some text in a page with
function anotherFunction() {
$(window).scrollTop($("table:contains('some text'):last").offset().top);
}
How can I use the variable date from my Javascript code to scroll to this text in my table, using JQuery? Essentially, I'd like a button that jumps to today's date in my table.
I'm pretty sure there are better ways to do this also, but I am an absolute beginner in programming and I don't know much, so I'm sorry for being very blunt and thank you!
Nov-17-2021vs17-Nov-2021so they won't match unless you do a date parse.