Javascript 如何获取不同图像jquery的特定src?

Javascript 如何获取不同图像jquery的特定src?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在开发拖放web应用程序。我的问题是我可以得到第一个拖动元素的src。但当我拖动第二个元素时,它将得到与第一个元素相同的src。我使用$this.find.drag.attrsrc获取图像的src 比如说, 拖动第一个元素src->item\u head/head45.png 拖动第二个元素src->item_head/head45.png,但拖动第二个 元素src->item_head/head46.png $this.find.drag将不会返回单个元素。使用。最后一个 如果它解决了你的

我正在开发拖放web应用程序。我的问题是我可以得到第一个拖动元素的src。但当我拖动第二个元素时,它将得到与第一个元素相同的src。我使用$this.find.drag.attrsrc获取图像的src

比如说,

拖动第一个元素src->item\u head/head45.png

拖动第二个元素src->item_head/head45.png,但拖动第二个 元素src->item_head/head46.png

$this.find.drag将不会返回单个元素。使用。最后一个


如果它解决了你的问题,请考虑投票,并把它标记为正确答案。我不能在这个时候投票,但我已经把它标记为正确答案。非常感谢你帮助我。真管用!!!!
<div class="wrapper">
 <div id="options">
    <?php 
        $strSQL = "SELECT * FROM item_head ORDER BY ihead_id DESC";
       $objQuery = mysqli_query($con,$strSQL);
       while($row = mysqli_fetch_array($objQuery)){
   ?>               
    <img width="150" height="120" src="item_head/<?php echo $row['filesName'];?>" id="drag1" class="drag"></img>
   <?php}?>
</div>
$("#frame").droppable({
        drop: function(ev, ui) {
            if (ui.helper.attr('id').search(/drag[0-9]/) != -1){
                counter++;
                var element = $(ui.draggable).clone();
                element.addClass("tempclass");
                $(this).append(element);
                $(".tempclass").attr("id","clonediv"+counter);
                $("#clonediv"+counter).removeClass("tempclass");
                //Get the dynamically item id
                draggedNumber = ui.helper.attr('id').search(/drag([0-9])/)
                itemDragged = "dragged" + RegExp.$1;
                var objsrc = $(this).find(".drag").attr("src");
                alert(objsrc);
                console.log(itemDragged)
                $("#clonediv"+counter).addClass(itemDragged);
                var objtop  = ui.offset.top - $(this).offset().top;

            }
        }
});
$("#frame").droppable({
        drop: function(ev, ui) {
            if (ui.helper.attr('id').search(/drag[0-9]/) != -1){
                counter++;
                var element = $(ui.draggable).clone();
                element.addClass("tempclass");
                $(this).append(element);
                $(".tempclass").attr("id","clonediv"+counter);
                $("#clonediv"+counter).removeClass("tempclass");
                //Get the dynamically item id
                draggedNumber = ui.helper.attr('id').search(/drag([0-9])/)
                itemDragged = "dragged" + RegExp.$1;
                var objsrc = $(this).find(".drag").last().attr("src");
                alert(objsrc);
                console.log(itemDragged)
                $("#clonediv"+counter).addClass(itemDragged);
                var objtop  = ui.offset.top - $(this).offset().top;

            }
        }
});