0
我想用Jquery戳圖像。這幾乎完成了,但我無法爲獲得的克隆定義一個ID。請幫幫我。我下面的代碼給出:我需要使用jquery戳圖像
//Make element click
$(".drag").click(function(ev){
var currentid = ev.target.id.substr(4,5)
test11 = $(this).attr('id');
$("#frame").css("cursor","url(images/Stamp_icon.png),auto");
correct = "#"+test11;
cloneobj = true;
});
//stamp the object when click
$("#frame").click(function(e) {
if(e.pageX>=160 && e.pageX<=950){
if(e.pageY>=210 && e.pageY<=580){
if(cloneobj == true && correct != "null"){
clonecounter++
var o = {
left: e.pageX,
top: e.pageY
};
var obj = $(correct).clone().appendTo('#frame').show(0).offset(o);
clonearr.push(obj)
$(correct).attr("class","duplicateClone");
}
}
}
})
//Delete obj
$(".delbtn").click(function(){
correct = "null";
$("#frame").css("cursor","default");
if(clonecounter>0){
$(clonearr[clonecounter]).remove();
clonearr.pop(clonecounter)
clonecounter--;
}
})
請讓js小提琴的代碼 –