http://jsfiddle.net/5DCZw/2/ i found this fiddle on the website here, and I cant figure out how to add mu开发者_Go百科ltiple textboxes that would also be dropable.
Or with a class:
<input type="text" id="droppable1" class="droppable" />
<input type="text" id="droppable2" class="droppable" />
<input type="text" id="droppable3" class="droppable" />
...
$(".droppable").droppable({
hoverClass: 'active',
drop: function(event, ui) {
this.value = $(ui.draggable).text();
}
});
so you can also style all of them using css
Simple. Simply add more selectors to your .droppable()
line:
$(function() {
$(".draggable").draggable({
revert: true,
helper: 'clone',
start: function(event, ui) {
$(this).fadeTo('fast', 0.5);
},
stop: function(event, ui) {
$(this).fadeTo(0, 1);
}
});
$("#droppable, #droppable2").droppable({ // ***
hoverClass: 'active',
drop: function(event, ui) {
this.value = $(ui.draggable).text();
}
});
});
Example here. I'd recommend adding a class if you're using a bunch of inputs, as using $(this)
will only point to the current object (input).
$("#droppable2").droppable({
hoverClass: 'active',
drop: function(event, ui) {
this.value = $(ui.draggable).text();
}
});
$("#droppable3").droppable({
hoverClass: 'active',
drop: function(event, ui) {
this.value = $(ui.draggable).text();
}
});
$("#droppable4").droppable({
hoverClass: 'active',
drop: function(event, ui) {
this.value = $(ui.draggable).text();
}
});
and so on...
http://jsfiddle.net/5DCZw/144/
精彩评论