开发者

jQuery - Call function when dropping div

开发者 https://www.devze.com 2023-04-01 18:22 出处:网络
I want to run function insertHouse() when dropping div#Draggable. I can\'t manage to make it work. You can see me trying to call it in the second line from the bottom. What am I doing wrong?

I want to run function insertHouse() when dropping div#Draggable. I can't manage to make it work. You can see me trying to call it in the second line from the bottom. What am I doing wrong?

<img src="images/door1.jpg" id="draggable">
<div id="items"></div>

// Place house;
function insertHouse()
{
blablabla
}

$( init );

function init() {
  $('#makeMeDraggable').draggable();
  $('body').droppable( {
    drop: handleDropEvent
  } );
}

function handleDropEvent( event, ui ) {
  function insert开发者_C百科House();
}


Following code will work...

function init() {
  $('#makeMeDraggable').draggable();
  $('body').droppable( {
drop: function(event, ui){
insertHouse();
}
  } );
}
0

精彩评论

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