How do I add a textbox to my other jQuery click function?
Posted
by marcamillion
on Stack Overflow
See other posts from Stack Overflow
or by marcamillion
Published on 2010-04-12T08:59:49Z
Indexed on
2010/04/12
9:03 UTC
Read the original article
Hit count: 353
Right now, my script adds a box to the cursor when I click on an image, as can be seen in the following code. Please note, this is jQuery.
$(function() {
var tag_box = $("<div>").appendTo("body").css({"width":"40px", "height":"40px", "border":"4px solid #000000", "position":"absolute", "display":"none", "padding":"15px"});
$("#image-wrapper").live('click', function(e){
tag_box.css({"left": e.pageX - 40, "top": e.pageY - 40, "display":"block"});
});
I would like to add a text field to appear right below that tag_box on that same click. I tried to do this, but it hasn't worked out like I thought it would:
var comment_box = $("<label> Comment: <input type='text' name='comment' autocomplete='off'></label>");
$("#image-wrapper").live('click', function(){
$("body").append(comment_box);
});
Any assistance you can give me, would be greatly appreciated.
Thanks.
© Stack Overflow or respective owner