gpt4 book ai didi

jquery - 使用 a 将图像附加到另一个图像上并获取坐标,使其可拖动和删除

转载 作者:行者123 更新时间:2023-12-01 05:58:22 25 4
gpt4 key购买 nike

在此处输入代码在此处输入代码`好的,这样我就有了一个图像,我将在单击按钮时将另一个图像附加到它上面。图像附加,我得到了位置的坐标。我还使用jquery ui 制作了图像draggalbe。每次附加图像时,还会生成一个 div,其中包含单击的图像的坐标和区域。在新生成的 div 中,有一个删除按钮可以删除该分区。我需要使该删除按钮也删除与该 div 对应的附加的特定图像。我非常感谢任何有关这方面的帮助,谢谢。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MyMapImage</title>
<style type="text/css">
#container {
background: green;
width: 596px;
height: 218px;
position: relative;
cursor: crosshair;

}
#container img {
position: absolute;
opacity:0.95;
}

#container img.cross {
position: absolute;

}
</style>
<style type="text/css">
#draggable {font-size:x-large; border: thin solid black; width: 5em; text-align: center}
</style>



<script type="text/javascript">
$(document).ready(function() {
$(".WindSh").click(function(e) {
e.preventDefault();
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
var img = $('<img>');
img.css('top', y-23);
img.css('left', x-23);
img.attr('src', 'cross.png');
img.attr('class','cross');
img.appendTo('#container');
img.draggable({
containment: "parent"
});
})

});
</script>
<script type="text/javascript">

$(document).ready(function() {
$('.WindSh').click(function(e) {
var offset = $(this).offset();
var xz= e.clientX - this.offsetLeft;
var yz= e.clientY - offset.top;

if (parseInt(xz)>= 38 && parseInt(xz)<=200 && parseInt(yz)>=15 && parseInt(yz)<=98)
{
$('<div/>').append((xz) + ", " + (yz) + " ; " + "You have selected Region 1")
.appendTo('#coordinates');
}
else if (parseInt(xz)> 200 && parseInt(xz)<=401 && parseInt(yz)>=15 && parseInt(yz)<=98)
{
$('<div/>').append ((xz) + ", " + (yz) + " ; " + "You have selected Region 2")
.appendTo('#coordinates');

}
else if (parseInt(xz)> 401 && parseInt(xz)<=540 && parseInt(yz)>15 && parseInt(yz)<=98)
{
$('<div/>').append ((xz) + ", " + (yz) + " ; " + "You have selected Region 3")
.appendTo('#coordinates');
}
else if (parseInt(xz)> 12 && parseInt(xz)<=200 && parseInt(yz)>98 && parseInt(yz)<=186)
{
$('<div/>').append ((xz) + ", " + (yz) + " ; " + "You have selected Region 4")
.appendTo('#coordinates');
}
else if (parseInt(xz)> 200 && parseInt(xz)<=401 && parseInt(yz)>98 && parseInt(yz)<=186)
{
$('<div/>').append ((xz) + ", " + (yz) + " ; " + "You have selected Region 5")
.appendTo('#coordinates');
}
else if (parseInt(xz)> 401 && parseInt(xz)<=540 && parseInt(yz)>98 && parseInt(yz)<=186)
{
$('<div/>').append ((xz) + ", " + (yz) + " ; " + "You have selected Region 6")
.appendTo('#coordinates');
}
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('.hide').click(function(){
$('.cross').hide();
});
});
</script>

</head>
<body
<div id="container"><img class="WindSh" src="WindShield.png"></div>
<div>Coordinates x,y: <span id="coordinates"></span></div>
<input type="button" class="hide" value="hide">

</body>
</html>

最佳答案

所以我必须将此图像 x 附加到另一个图像 y 之上。图像 x 应该给出附加到图像 y 上的坐标。第二,当附加图像 x 时,它会打开另一个 div,其中显示附加图像 x 的坐标。在该 div 中还有一个删除按钮。删除按钮当前删除该行,但我也希望该删除按钮删除与该 div 对应的附加图像。谢谢

关于jquery - 使用 a 将图像附加到另一个图像上并获取坐标,使其可拖动和删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13243999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com