hi I have a div which contains just a image like this :
(div)
(img. …)
(/div)
Now,I want to create a mark in the image ,s I use :
$(div).append((img src =mark.jpg id =mark)).
then set its position :
$(div img#mark).position(…)
Here I don't know how to set it.
I just want to make the mark's position within its parent .
In fact ,what I want like the google map ,when you search something in google map ,the results will be marked in the map .
Of course,my require is much easy.
I have thought to get the offset of the parent ,then caculate the really position of the mark image .
But I can't make it. Any idea ?
Btw ,I ask this in my phone ,so I can't make a pretty format.
You could use CSS:
div { position: relative; }
div img#mark { position:absolute; }
And then set the position like this:
$("div img#mark").css({
'top': '10px',
'left': '10px'
});
Does that do what you meant?
$("div").css('position', 'relative');
$("div img#mark").css({
position: 'absolute',
top: '0px',
left: '0px'
});
Change top and left values to suit where you would like to position the mark.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With