校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > PHP+jQuery實(shí)現(xiàn)雙擊修改table表格功能示例

PHP+jQuery實(shí)現(xiàn)雙擊修改table表格功能示例

熱門標(biāo)簽:上海公司外呼系統(tǒng)線路 電梯外呼線路板維修視頻 地圖標(biāo)注風(fēng)向標(biāo) 安陽自動外呼系統(tǒng)價格是多少 芒果電銷機(jī)器人 銀川ai電話機(jī)器人 臨沂智能電銷機(jī)器人軟件 十堰ai電話機(jī)器人效果怎么樣 浙江外呼電話系統(tǒng)軟件

本文實(shí)例講述了PHP+jQuery實(shí)現(xiàn)雙擊修改table表格功能。分享給大家供大家參考,具體如下:

!DOCTYPE html>
html lang="en">
head>
  meta charset="UTF-8">
  title>即點(diǎn)即改/title>
  script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js">/script>
/head>
body>
?php
$con = array(
  array("id"=>1,"姓名"=>"張三","性別"=>"女"),
  array("id"=>2,"姓名"=>"李四","性別"=>"男"),
  array("id"=>3,"姓名"=>"王五","性別"=>"男"));
 // print_r($con);die;
?>
  table align="center" border="1">
  ?php foreach ($con as $key => $v): ?>
    tr id="?= $v['id'];?>">
      td signs="user_name" style="width:100px">
        input style="border:0; text-align: center; width:60px; background: #fff;"
        type="text" disabled="disabled" readonly="readonly" value="?= $v['姓名'];?>" >
      /td>
      td signs="user_sex" style="width:100px">
        input style="border:0; text-align: center; width:60px; background: #fff;"
        type="text" disabled="disabled" readonly="readonly" value="?= $v['性別'];?>" >
      /td>
    /tr>
  ?php endforeach; ?>
  /table>
/body>
/html>
script>
  //雙擊觸發(fā)事件
  $("tbody>tr>td").dblclick(function(){
    //獲取到 當(dāng)前 input 下的元素(原值)
    window.olds = $(this).children('input').val();
    if(olds==undefined)
    {
      return false;
    }
    var signs = $(this).attr('signs'); //獲取屬性值(這些值方便php后臺的操作)
    var user_id = $(this).parent().attr("id"); //接受當(dāng)前點(diǎn)擊的ID(tr里的id)
    //雙擊之后可以修改
    $(this).find('input').attr("disabled",false);
    $(this).find('input').attr("readonly",false);
    $(this).find('input').css("border",'1px solid deepskyblue');
    $(this).find('input').attr('id', signs + "_" + user_id);  //方便下面失去焦點(diǎn)事件 找ID(沒有這個無法定位到tr里面的id屬性)
    //循環(huán)這些值從而判斷是修改數(shù)據(jù)的類型,對一些特殊類型的數(shù)據(jù)進(jìn)行特殊處理
    switch(signs){
      case 'user_name':
       $("#" + signs + "_" + user_id).focus().on("blur",function(){
         var content = $(this).val();
         if(content!=olds)  //與原值不同則傳到后臺
         {
           // alert(user_id);alert(signs);alert(content);
           /*
           通過getJSON將數(shù)據(jù)傳輸?shù)胶笈_
           USER_ID
           SIGNS
           CONTENT
           */
         }
         $(this).attr('disabled', 'disabled');
        $(this).attr('readonly', 'readonly');
        $(this).css('border', '0');
        $(this).css('background', '#fff');
        $(this).css('text-align', 'center');
       })
      break;
      case 'user_sex':
       $("#" + signs + "_" + user_id).focus().on("blur",function(){
         var content = $(this).val();
         if(content!=olds)
         {
           // alert(user_id);
         }
         $(this).attr('disabled', 'disabled');
        $(this).attr('readonly', 'readonly');
        $(this).css('border', '0');
        $(this).css('background', '#fff');
        $(this).css('text-align', 'center');
       })
    }
  })
/script>

運(yùn)行效果如下:

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP數(shù)組(Array)操作技巧大全》、《PHP常用遍歷算法與技巧總結(jié)》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計(jì)算法總結(jié)》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《php字符串(string)用法總結(jié)》及《php常見數(shù)據(jù)庫操作技巧匯總》

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

您可能感興趣的文章:
  • JS/jQuery實(shí)現(xiàn)超簡單的Table表格添加,刪除行功能示例
  • jquery實(shí)現(xiàn)自定義樹形表格的方法【自定義樹形結(jié)構(gòu)table】
  • JS拖動選擇table里的單元格完整實(shí)例【基于jQuery】
  • jQuery-ui插件sortable實(shí)現(xiàn)自由拖動排序
  • 使用jQuery給Table動態(tài)增加行、清空table的方法
  • js與jQuery實(shí)現(xiàn)獲取table中的數(shù)據(jù)并拼成json字符串操作示例
  • jQuery實(shí)現(xiàn)table表格checkbox全選的方法分析
  • jQuery+datatables插件實(shí)現(xiàn)ajax加載數(shù)據(jù)與增刪改查功能示例
  • JQuery實(shí)現(xiàn)table中tr上移下移的示例(超簡單)
  • 基于jQuery獲取table數(shù)據(jù)發(fā)送到后端

標(biāo)簽:遵義 常州 武威 荊門 遂寧 吐魯番 徐州 寧夏

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP+jQuery實(shí)現(xiàn)雙擊修改table表格功能示例》,本文關(guān)鍵詞  PHP+jQuery,實(shí)現(xiàn),雙擊,修改,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PHP+jQuery實(shí)現(xiàn)雙擊修改table表格功能示例》相關(guān)的同類信息!
  • 本頁收集關(guān)于PHP+jQuery實(shí)現(xiàn)雙擊修改table表格功能示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 津南区| 宁武县| 衡阳市| 思南县| 金川县| 张家界市| 延安市| 城步| 兴义市| 辽阳县| 通山县| 卢湾区| 达州市| 河曲县| 大余县| 华亭县| 河间市| 沁阳市| 阳江市| 田阳县| 灵寿县| 科技| 黑龙江省| 舒城县| 繁昌县| 汾西县| 新竹县| 临桂县| 义乌市| 西藏| 合川市| 精河县| 九龙坡区| 十堰市| 体育| 东至县| 金山区| 安乡县| 徐州市| 温州市| 林西县|