So, I'm trying to add an icon to the image as soon as someone βmarkedβ a part of the image, that is, submitted a form.
How to do it in jQuery?
Just to be clear ... imagine you are on flickr and you see an image. You want to add an annotation, you click on the image where you want, and it shows you the form field. You enter the information you want, and then, after you have done this, a small image will appear on the image that shows where you left the comment.
Any ideas?
Edit - see code:
<script type="text/javascript">
$(function() {
var tag_box = $("<div>").appendTo("body").css({
"width": "40px",
"height":"40px",
"border":"4px solid #000000",
"position":"absolute",
"display":"none",
"padding":"15px"
});
var comment_box = $("<form action='#'><input id='comment' type='text' name='comment' placeholder='Add comment'></form>").appendTo(tag_box).css({"position":"absolute"});
var comment_icon = $("<img src='images/asterisk_yellow.png' width='16' height='16' alt='Comment'>");
$("#image-wrapper").live("click", function(e) {
tag_box.css({
"left": e.pageX - 40,
"top": e.pageY - 40,
"display": "block"
})
.after(comment_box.css({
"left": e.pageX - 65,
"top": e.pageY + 40
}));
return false;
});
$("form").submit(function() {
var params = $(this).serialize();
$("form")[0].reset();
return false;
});
});
</script>
<body>
<div align="center">
<img src="images/image1.gif" width="760" height="182" alt="image1" id="image-wrapper">
</div>
</body>
, , - ( , , ). , (), () ... "". , -, . (), jQuery, .