Reputation: 620
How can I insert a img wherever I click on the page?
I have the following code:
$(document).click(function(e){
var x = e.pageX;
var y = e.pageY;
var string = x +','+ y;
//alert(string);
$('.marker').css(
{
'left': x +'px',
'top': y +'px'
},{
duration:1000,
})
});
But this only moves the img around the page. I need to add multiple copies and POST to php url.
Thanks!
Upvotes: 2
Views: 93
Reputation: 146201
You mean this ?
$(document).click(function(e){
var x = e.pageX;
var y = e.pageY;
var string = x +','+ y;
//alert(string);
$('.marker:first').clone().css({
'left': x +'px',
'top': y +'px',
'position':'absolute'
}).appendTo('body')
});
DEMO.
Upvotes: 2