i have an script that i want to generate i div where ever user clicks and that div stays there so now i have this jquery script
$(document).ready(function() {
$('body').click(function(e) {
var offset = $(this).offset();
$('#x_axis').html(e.clientX - offset.left);
var x = (e.clientX - offset.left);
$('#y_axis').html(e.clientY - offset.top);
var y = (e.clientY - offset.top);
$('body').append('<div id="bloom" style="position: relative; left: HERE I WANT TO PLACE X;">asd</div>');
$('#bloom').css('left', x);
$('#bloom').css('top', y);
});
});
now on this line i want to add my X and Y variables to left and top attribute :
$('body').append('<div id="bloom" style="position: relative; left: HERE I WANT TO PLACE X;">asd</div>');
any idea how this can be done ?? or any better way to make this thing that when user click on each part of page a div generates there
$('body').append($('<div>').attr('id', "bloom").css({ position: "relative", left: x }).text("asd"));