开发者

jquery drag drop values with php

i have to objects / elements. one is [ 4 images with different ids ] and [ a div with id container ]....

i want to make images dragable and alert the id of image if it is dragged and dropped properly inside container div.......

and then send its value to mysql with php and jqu开发者_如何学编程ery $.ajax


Use jQuery UI's Dropable

$( 'selector for DIV' ).droppable ( {
    drop: function ( event, ui ) {
        // ui.draggable is a jQuery object representing your image
    }
} );


$('#container').droppable({
   accept: 'img'
  drop: function(event, ui){
    var id=$(ui.draggable).attr('id');
    $.ajax({
      url: 'myurl.php',
      data: {id: id},
      success: function(data){
        //do something with data
      }

    })
  }
});
$('img.draggable').draggable();//assuming all draggable images have a draggable class
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜