<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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.