When working with HTML documents, we often come across various HTML elements like div, p, img, and more.
Many of these elements are dynamically created, especially if helpful CSS such as "position: absolute;" is used.
After every onClick event, it is necessary for the element to be brought to the front of other elements. This can be achieved by using:
element.parentNode.appendChild(element);
or
element.parent().append(element);
Alternatively, you can do it like this:
// For example, using CSS:
$('#ObjId').css('z-index', HighestIndx+1 );
Personally, I prefer using appendChild
because adding the z-index property directly to the element can sometimes cause issues.
However, I am unsure which approach is better - using z-index or append/appendChild. So my question is: Which is the better method to use - z-index or append/appendChild? Thank you.