I have a table and in one column I have links. When links are clicked I display a div over with additional data. Currently i have those divs hidden and show them on click. i am wondering if I should put that div into a function and when item is clicked — append the div to the clicked item..
Am I on the right track?
Shall I use appendTo or insertAfter ?
Hiding/showing an element isn’t a bad practice and commonly done for performing the kind of scenario you’re talking about. But you may as well append the element, it depends on what kind of strategy renders your JavaScript code cleaner and more maintainable.
To what regards the difference about appendTo or insertAfter depends a bit on what you want to achieve. Consider the following HTML
Performing
would result in
while
would result in