I have the following code and then in a function out of all these functions I want to do a getElementById, but the created canvases do not have ID, they told me that I should add it to id inside the function per, but I'm disoriented, if someone knows please help.
Code :
$(document).ready(function(){
function per() {
console.log("per()");
var $canvas = $('<canvas></canvas>').css({
'border-radius': '5px',
'padding': '0',
'margin': '0',
'width': '200px',
'height': '200px',
//'position': 'absolute',
'right': '15px',
'bottom': '15px',
'background-color': 'blue'
});
$('body').append($canvas);
}
$('body').append('<canvas id="minimap"></canvas>');
$('#minimap').css({
'background': 'rgba(1,1,1,0.7',
'border-radius': '0px',
'border': '1px solid rgba(255,255,255,0.2)',
'padding': '0',
'margin': '0',
'width': '200px',
'height': '200px',
'position': 'absolute',
'right': '15px',
'bottom': '15px'
});
b.forEach(per);
});
function obtener() {
document.getElementById(que hago?)
}