Whenever a user selects a checkbox in a table row and saves it, a new container is created to store the data in a specific format for that particular row.
Note: The data displayed in the table is sourced from JSON.
Additionally, users have the option to manually add data to the same container using a form.
Later on, all these containers or data holders will be appended to a parent container in the DOM.
Although I have successfully managed to swap these data containers, I am facing an issue with disabling or hiding buttons for the first and last containers.
Below is the script I am using:
<script>
// Code goes here
</script>
The top button for the first data holder should be disabled as there is no container above it to swap. Similarly, the down button for the last data holder should be disabled as there is no container below it to swap with.
I'm unsure about what might be wrong with my implementation?
Note: Everything works perfectly when using hardcoded data holders instead of generating them dynamically.