Div follows the position of the mouse to show and hide

now, through a set of data, 4 div., are rendered in a loop. Click events are set for div, which can be selected, and 4 div can be selected. There is also a button on the page. The button is hidden, now click to select a div, this hidden button will appear in the right position of the selected div, and then select the second div, and this button will be displayed in the right position of the second div, and so on, each selected div, button will appear in the right position of the last selected div. Is there any good way to achieve this effect?

Mar.08,2022

each div corresponds to a button. Whether the button is hidden or not depends on the index of the last div you currently selected

.
Menu