0
People want to improve the code of a drag drop, follow the code
<img src="image.png" class="card01">
<img src="image.png" class="card02">
<div class="bloco01"></div>
<div class="bloco02"></div>
$( function() {
$( ".card01" ).draggable({ revert: "invalid" });
$( ".bloco01" ).droppable({
accept: ".card01",
drop: function( event, ui ) {
$( this ).addClass("ui-state-highlight");
$( ".card01" ).addClass('dropped');
}
});
$( ".card02" ).draggable({ revert: "invalid" });
$( ".bloco02" ).droppable({
accept: ".card02",
drop: function( event, ui ) {
$( this ).addClass("ui-state-highlight");
$( ".card02" ).addClass('dropped');
}
});
});
Only I don’t want to have to repeat draggable and droppable on for every card I create, isn’t there any way to do it using the date? for example by creating a date-hit.
Why not create a function for it?
– Woss
Could you give me an example ?
– Thi100