I'm sorry if my explanation is a bit difficult to comprehend. Here is the code snippet in question:
names.push(newName);
var strName = newName;
var newName = document.createElement('p')
newName.setAttribute('id', newName);
document.body.appendChild(newName);
newName.innerText = strName;
$(newName).css('position','absolute')
$(newName).css('top', y);
$(newName).css('left', x);
updateXY();
When a user creates a new div with a custom name, everything works as expected. However, I am struggling to figure out how to detect when a user-clicks on any of these dynamically created and named divs.
For instance:
If a user creates divs named 'hello' and 'goodbye', I can't simply use $('#hello').click(function() {}); because I won't know which specific div the user chose to create.
Additionally, the array names contains the names of all the created divs, in case that information is helpful. Any assistance on this matter would be greatly appreciated. Thank you.