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

PHP+jQuery實(shí)現(xiàn)即點(diǎn)即改功能示例

 更新時(shí)間:2019年02月21日 08:38:18   作者:ztblog  
這篇文章主要介紹了PHP+jQuery實(shí)現(xiàn)即點(diǎn)即改功能,涉及php數(shù)組讀取、遍歷及jQuery事件響應(yīng)與動(dòng)態(tài)修改頁(yè)面元素屬性相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP+jQuery實(shí)現(xiàn)即點(diǎn)即改功能。分享給大家供大家參考,具體如下:

<!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 pid="<?= $v['id'];?>">
      <td><span class="up" style="cursor:pointer;"><?= $v['姓名'];?></span></td>
      <td><?= $v['性別'];?></td>
    </tr>
  <?php endforeach; ?>
  </table>
</body>
</html>
<script>
  //即點(diǎn)即改
  $(document).on("click",".up",function(){
    var content = $(this).text(); //獲取到當(dāng)前點(diǎn)擊對(duì)象的值
    var pid = $(this).parents("tr").attr('pid');  //通過(guò)attr 獲取到設(shè)置的屬性(pid)
    //當(dāng)點(diǎn)擊修改文字時(shí) 變成文本框并且獲取到原值(content)
    $(this).parent().html("<input type='text' class='fo' value='" + content + "'/>");
    $(".fo").focus(); //光標(biāo)
    $(".fo").blur(function(){
      //獲取到修改后的值
      var val = $(".fo").val();
      //
      /*
      將所有修改信息傳到后端
       */
      $(this).parent().html("<span class='up' style='cursor:pointer;'>"+val+"</span>");
    })
  })
</script>

運(yùn)行結(jié)果:

更多關(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常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總

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

相關(guān)文章

最新評(píng)論