我正在设计一个网站,它就像带有贴纸的公告板。所以每个贴纸都有一个关闭按钮。但是我找不到用户单击关闭按钮的贴纸的 ID。
stickerId = 1;
function createSticker(jsonNewSticker){ // receives json
str = "<b>Email:</b> "+ jsonNewSticker.email+
"</br> <b>Title:</b> "+ jsonNewSticker.title+
"</br> <b>Summary:</b> "+ jsonNewSticker.summary+
"</br> <b>Description:</b> "+ jsonNewSticker.description +
"</br> <b>Entry expires: </b>" + jsonNewSticker.expiration_date;
$("#mainForSticks").prepend("<div id= seq-"+ stickerId +" ></div>");
$("#seq-"+ stickerId).attr("class","sticker");
$("#seq-"+ stickerId).html(str);
$("#seq-"+ stickerId).append("<div id=report><a class=link href=javascript:reportCounter()>Report</a></div>"); // report
$("#report").attr("class","reportText");
$("#seq-"+ stickerId).append("<div id=deleteSticker><a class=link href=javascript:deleteSticker()><b>X</b></a></div>"); // delete
$("#deleteSticker").attr("class","delSticker");
//currentId = $(this).attr('id');
stickerId++;
}
所以这里每个贴纸都有一个id:seq-1 seq-2 seq-3 ...
function deleteSticker(){
// how can I get id of specific sticker
}