如何在拖动数据时获取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 ?? –