I have two divs that are float:left:
<div id="inventor">
<table>
<tr id="1"><td>Alexander Graham Bell</td></tr>
<tr id="2"><td>Thomas Edison</td></tr>
<tr id="3"><td>Nicholas Tesla</td></tr>
</table>
</div>
<form>
<div id="invention">
<table>
<tr><td><input name="answer1" />Tesla coil</td><td>Explanation</td></tr>
<tr><td><input name="answer2" />Telephone</td><td>Explanation</td></tr>
<tr><td><input name="answer3" />Phonograph</td><td>Explanation</td></tr>
<tr><td><input name="answer4" />Light bulb</td><td>Explanation</td></tr>
</table>
</div>
</form>
and I want to be able to drag the inventor over to the invention.
$("#inventor tr").draggable({
revert: "valid"
});
$("#invention tr").droppable({
drop: function(event, ui) {
var inventor = ui.draggable.text();
$(this).find("input").val(inventor);
}
});
I was able to get this working with list elements, but now that I'm adding an explanation to the invention table, I'd like to use a table on the left-hand side for styling purposes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…