I have a page with lots of divs, like a form filling page (not statically fixed but generated dynamically).
Here I need to create a new div and place it in a particular [x,y] position which is also not fixed but will get dynamically while rendering.
So my question is how to place a newly created div in a particular [x,y] position using javascript/jquery?
I am trying like this but the div is not appearing:
const showFormFieldErrorMessage = function (data, message) {
const errorMsg = message || 'This field is required.';
const errorElem = document.createElement('div');
errorElem.style.backgroundColor = '#ff0000';
errorElem.innerHTML = errorMsg;
errorElem.style.top = `${(data && data.position && data.position.posy) ? data.position.posy : '0'}px`;
errorElem.style.left = `${(data && data.position && data.position.posx) ? data.position.posx : '0'}px`;
errorElem.zIndex = 900;
};
NOTE: The parameter data is where I get the position details in runtime.
Thanks in advance!!