<div class="result_wrap">
<div class="result_content">
<table class="list_tab">
<tr>
<th>级别</th>
<th>占比</th>
<th>操作</th>
</tr>
<foreach name="res2" item="v">
<tr>
<th>{$v.name}</th>
<th class="res">{$v.bili}</th>
<th><a href="">修改</a></th>
</tr>
</foreach>
</table>
</div>
</div>
</form>
<script>
$('.res').click(function(){
var th = $(this);
var html = th.html();
var input = $("<input type='text' value='" + html + "'/>");
th.html(input);//附上input
//再次点击不变
input.click(function(){return false;});
//自动获取焦点
input.trigger("focus");
//文本框失去焦点变回来
input.blur(function(){
var val = $(this).val();
if (val != html) {
th.html(val);
//下面开始根据你的情况,在写ajax
} else {
th.html(val);
}
})
})
</script>
<div class="result_content">
<table class="list_tab">
<tr>
<th>级别</th>
<th>占比</th>
<th>操作</th>
</tr>
<foreach name="res2" item="v">
<tr>
<th>{$v.name}</th>
<th class="res">{$v.bili}</th>
<th><a href="">修改</a></th>
</tr>
</foreach>
</table>
</div>
</div>
</form>
<script>
$('.res').click(function(){
var th = $(this);
var html = th.html();
var input = $("<input type='text' value='" + html + "'/>");
th.html(input);//附上input
//再次点击不变
input.click(function(){return false;});
//自动获取焦点
input.trigger("focus");
//文本框失去焦点变回来
input.blur(function(){
var val = $(this).val();
if (val != html) {
th.html(val);
//下面开始根据你的情况,在写ajax
} else {
th.html(val);
}
})
})
</script>