2016-06-12 20 views
-1

我有一個可放置李元素的列表。當我將它拖放到表上時,我想將li元素的值插入到表值中。但我不知道用什麼代碼來檢測li元素的值....這是我的代碼。如何從一個可拖動的li jquery獲取值?

$(function() 
{ 
$("#planningData").sortable(
    { 
    revert: true 
    }); 
$(".hName").droppable(
    { 
    drop: function (event, ui) 
     { 
     var draggableId = ui.draggable.attr.val(); 

     //Below is where I am trying to detect what the text value of the li is. 
     var droppableId = $(this).siblings(".hInput").attr('id'); 
     $(this).html(draggableId); 

     var hourData = draggableId; 
     var hourNumber = droppableId; 
     alert(hourData, hourNumber); 
     $.post("UpdateTime.php", 
     { 
      loginName: "<?php echo $user; ?>", 
      hourData: hourData, 
      hourNumber: hourNumber 
     }, 
    function(result) 
     { 
      alert(result); 
     }); 
     } 
    }) 
}); 

回答