Py学习  »  Jquery

用jquery获取th的ID

Ezra • 6 年前 • 1611 次点击  

我有这张桌子:

  <th id="a" width="250">Backlog</th>
  <th id="b" width="250">Wip</th>
  <th id="c" width="250">Testing</th> 
  <th id="d" width="250">DOD</th>
</tr>

我的要求 enter image description here

我有4列积压,在制品,测试,国防部。如果我从积压工作中拖拽到测试中,我想得到拖拽列ID,也就是说,我想把它保存到数据库中。我试过这个:

jQuery(function() {
  jQuery(".draggable").draggable({
    containment: "#containment-wrapper",
    scroll: false,
    stop: function(event, ui) {
      // Show dropped position.
      var id = $(this).attr('id');
      var trid = $(this).closest('tr').attr('id');
      alert(trid);
      var Stoppos = $(this).position();
      model = {
        id: id,
        left: Stoppos.left,
        top: Stoppos.top
      };

      $.ajax({
        url: "/scrum/save",
        type: "post",
        data: model,
        success: function(data) {
          jQuery.HP({
            title: "Success!",
            message: "Saved..."
          });
        },
        error: function() {
          //  alert('error is saving');
        }
      });
    }
  });
});

我试图获取当前列的ID,但没有成功。

var trid = $(this).closest('th').attr('id'); alert(trid); 

我怎样才能拿到身份证?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38794
 
1611 次点击  
文章 [ 1 ]  |  最新文章 6 年前