Currently, I am working on a website where I am building a timeline using AJAX. I encountered an issue while trying to set the onclick event on each table row.
I initially used a class selector but it did not produce any effect. After reading a post on Stackoverflow, I learned that I needed to set the onclick on the closest static item, but still no luck.
Here are the methods I tried:
$(".timeline").on("click","table-row",function () { alert("we") ;});
and
$(".table-row").click(function () { alert("we"); });
The AJAX code snippet responsible for creating the timeline is as follows:
function createTavoli(salaSelect) {
$.ajax({
// AJAX request details here
});
}
What would be the most effective way to set the onclick event on the table-row class?
You can view a JSFiddle demonstration of the timeline construction.