Reputation: 2407
The following code changes a div's background-color
when another div
is dragged on it. How can I modify it it to change divs's text instead of background colour (for example I drop a div with a <p>Test</p>
inside it and I want to the div which was dragged onto to change its text to <p>Test</p>
code:
$(".snap").droppable({
drop: function (event, ui) {
var drag = ui.draggable;
var drop = $(this);
$(this).html(drag.html());
$(this).attr('name', drag.attr('id'));
debugger;
}
});
Please check my JSFiddle code which is not working:
Upvotes: 0
Views: 152
Reputation: 104775
You can do:
$(this).html(drag.html());
In place of:
$(this).css("background-color", drag.css("background-color"));
Upvotes: 2
Reputation: 3435
Replace
$(this).css("background-color", drag.css("background-color"));
with
drop.html(drag.html());
.
Upvotes: 2