mirror of
https://github.com/System-End/theseus.git
synced 2026-04-20 00:35:18 +00:00
20 lines
No EOL
621 B
JavaScript
20 lines
No EOL
621 B
JavaScript
import $ from 'jquery';
|
|
|
|
$('table.interactive').each(function() {
|
|
const $table = $(this);
|
|
const highlightedClass = 'highlighted';
|
|
|
|
$table.on('click', function(event) {
|
|
const $target = $(event.target);
|
|
const $newlySelectedRow = $target.closest('tr');
|
|
const $previouslySelectedRow = $table.find('tr.' + highlightedClass);
|
|
|
|
if ($previouslySelectedRow.length) {
|
|
$previouslySelectedRow.removeClass(highlightedClass);
|
|
}
|
|
|
|
if ($newlySelectedRow.length) {
|
|
$newlySelectedRow.toggleClass(highlightedClass);
|
|
}
|
|
});
|
|
}); |