亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

angularjs實(shí)現(xiàn)table表格td單元格單擊變輸入框/可編輯狀態(tài)示例

 更新時(shí)間:2019年02月21日 11:49:46   作者:小貓兒  
這篇文章主要介紹了angularjs實(shí)現(xiàn)table表格td單元格單擊變輸入框/可編輯狀態(tài),涉及AngularJS事件響應(yīng)及頁(yè)面table元素屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了angularjs實(shí)現(xiàn)table表格td單元格單擊變輸入框/可編輯狀態(tài)。分享給大家供大家參考,具體如下:

html部分:

<table>
  <thead>
  <tr >
   <th width="40px;">序號(hào)</th>
   <th>班次</th>
   <th>分組</th>
   <th>操作</th>
  </tr>
  </thead>
  <tbody>
  <tr ng-repeat="value in train_list" >
   <td width="40px;">{{value.id }}</td>
   <td>{{value.trainNumber}}</td>
   <td ng-click="edit($event)">{{value.groupId}}</td>
   <td>
    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow"  ng-click="move($event,'up')">上移</a>
    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow"  ng-click="move($event,'down')">下移</a>
    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow"  ng-click="del($event)">刪除</a>
   </td>
  </tr>
  </tbody>
</table>

js部分:

/**
 * 單元格單擊變編輯
 * @param e
 */
$scope.edit=function(e){
  var td = $(e.target);
  var txt = td.text();
  var input = $("<input type='text' value='" + txt + "' style='width:82px;height:26px;'/>");
  td.html(input);
  input.click(function() { return false; });
  //獲取焦點(diǎn)
  input.trigger("focus");
  //文本框失去焦點(diǎn)后提交內(nèi)容,重新變?yōu)槲谋?
  input.blur(function() {
    var newtxt = $(this).val();
     //判斷文本有沒(méi)有修改
    if (newtxt != txt) {
      td.html(newtxt);
    }
    else
    {
      td.html(newtxt);
    }
  });
};

更多關(guān)于AngularJS相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門(mén)與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)

希望本文所述對(duì)大家AngularJS程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論