如何拖动按钮并放下图像?

时间:2018-03-23 07:48:26

标签: javascript php jquery

代码:

<div class="col-md-8">
    <?php
        $query = " SELECT * FROM " .TB_OTHERS;

        $result1 = $conn->query($query);

        if($result1->num_rows >0)
        {
            while($rowquerycat = $result1->fetch_assoc())
            {
    ?> 

    <a href="test.php?id=<?php echo $rowquerycat['id']; ?> "> 
    <img style="padding-top:5%;" src="<?php echo $rowquerycat[KEY_NAME]; ?>" /></a>//display the image from database

    <?php 
            }
        }
    ?>
</div>
<div class="col-md-4">
    <div class="draggable">
        <center><a class="btn" style="width: 100%;color:white;">Button</a></center>
    </div>
</div>

我可以拖动按钮,但我无法将按钮放在图像上 帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

您可以使用jQuery droppable来删除图像上的按钮。 https://jqueryui.com/droppable/

以下是drop元素到特定元素的示例代码。

// #droppable is your image element which you need to make as droppable.
$( "#droppable" ).droppable({
      //Drop method called once you placed your element over the image.
      drop: function( event, ui ) {
       //Do you activity.
      }
});