如何在拖動數據時獲取td值?謝謝你,我需要幫助。
獲取數值數據javascript
這裏的JavaScript:
<script>
$(function() {
$("#sortable1, #sortable2").sortable({
connectWith: ".connected"
});
$("#sortable1, #sortable2").disableSelection();
$("#sortable1, #sortable2").sortable({ //here i want to alert the value when stop dragging
stop: function(event, ui) {
var val1 = $("td").innerHTML;
alert(val1);
}
});
});
</script>
這裏html代碼:
<?php if(!empty($query)){?>
<table id="todo" name="todo" class="table table-bordered" style='width:150px'><thead>
<tr>
<th style="text-align:center;background-color:#eee">TO DO</th>
</tr>
</thead>
<tbody id="sortable1" class="connected">
<?php foreach($query as $row):?>
<tr>
<td style="width:150px;background-color:#eee" id="<?php echo $row->list;?>" name="<?php echo $row->list;?>" value="<?php echo $row->list;?>"><?php echo $row->list;?></td>
</tr>
<?php endforeach;}?>
</tbody>
</table>
<table id="today" name="today" class="table table-bordered" style='width:150px'>
<thead>
<tr>
<th class="ui-state-highlight" style="text-align:center">TODAY</th>
</tr>
</thead>
<tbody id="sortable2" class="connected">
</tbody>
</table>
我不知道我的錯。請給我一個答案。
val()for td ... sure ?? –