To sort Table in Javascript

106 Views Asked by At

I have a situation where I need to sort table values based on the click on table headers. I did look at the examples using sortTable() but I'm not sure of how to call the function in javascript. I build the table in javascript using the below statement

content += "<table  border='1' style='width:1000px' id='AnnouncementTable'>";

where content is a JS variable. But for some reason I'm not able to get the sortTable() called. Could anyone help me in resolving the issue ?

Regards,

1

There are 1 best solutions below

0
On

You will need these 3 tools for this task. Your overall format would be to grab the button that the user is clicking using a query selector. Add an 'on click' type of event listener. Run a function that would handle, or run on click.