PHP之即点即改
html:
<td data-hide="1200" class="px12" id ="<?php echo $v['g_id'];?>" ><span class="click"><?php echo $v['g_price'];?></span></td> <script language="javascript" type="text/javascript"> $(function () { $(".click").click(function () { var _this = $(this); var old_val = _this.html(); _this.parent().html("<input type='text' name=" + old_val + " class='focus' value=" + old_val + " />"); $(".focus").focus(); $('.focus').blur(function(){ var _this = $(this); var new_val = _this.val(); var id = _this.parents().attr("id"); $.post("http://www.she.com/admin.php?rand=46&moduleid=32&file=gift&action=gift_jidianjigai",{g_price: new_val, g_id:id}, function(msg) { if(msg=='2'){ _this.parent().html('<span class="click">' + new_val + '</span>'); }else{ _this.parent().html('<span class="click">' + old_val + '</span>'); } }) }) }) }) </script>
php 后台处理
if(!empty($g_id)&&!empty($g_price)) { $res= $db->query("UPDATE `{$DT_PRE}gift` SET `g_price`='$g_price' WHERE `g_id`=$g_id"); if($res){ echo 2; }else{ echo 1; } }else{ echo 1; }