这是答案,
<input type="hidden" value="" id="x-text">
<input type="hidden" value="" id="y-text">
<input type="hidden" value="" id="content-text">
$("#canvas").click(function(e){
if(set==5){
var offset = $(this).offset();
$("#position").text((e.clientX - offset.left) + ", " + (e.clientY - offset.top));
$("#position").empty();
var input = $("<input type='text' value='' class='addtext' id='addText'>");
var save = $("<input type='button' class='save' value='save' id='save'>");
var discard = $("<input type='button' class='discard' value='discard' id='disc'>");
$("#position").append(input);
$("#position").append(save);
$("#position").append(discard);
$("#position").css('position', 'absolute');
$("#position").css('left', e.clientX - offset.left);
$("#position").css('top', e.clientY);
var xcor = $("#x-text");
var ycor = $("#y-text");
var ctext = $("#content-text");
var atext = $("#addText");
discard.click(function(){
$(this).parent().empty();
});
save.click(function(){
ctext.val(atext.val());
xcor.val(e.clientX - offset.left);
ycor.val(e.clientY);
$(this).parent().empty();
});
}
});
这是paperJSonMouseMove()
功能
function onMouseMove(event){
if(set == 5){
document.getElementById('save').onclick = function (){
m++;
var xcor = document.getElementById('x-text').value;
var ycor = document.getElementById('y-text').value;
var cont = document.getElementById('content-text').value;
var text = new PointText({
point: [xcor, ycor - 150],
content: cont,
fillColor: 'black',
fontSize: 25
});
var txt = new Group();
txt.addChild(text);
createElem('Notes', m, txt);
}
}
}