jQuery - 内联编辑表行 [英] jQuery - Edit a table row inline

查看:159
本文介绍了jQuery - 内联编辑表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含任意列和行的表。这个事实是无关紧要的,但实际上,我想要做的就是开发一个函数,将一行(或多行)转换为包含表中数据的一系列文本输入(如果单元格中没有数据,则为空)。 p>

我找不到任何人明确这样做的例子,所以我想知道人们认为这是找到解决方案的最佳方法。

解决方案

迭代行中的表格单元格,并用文本输入替换内容:

  function editRow(row){
$('td',row).each(function(){
$(this).html('< input type = textvalue ='+ $(this).html()+'/>');
});
}

您需要将相关的行/行明确传递给函数。


I have a table with arbitrary columns and rows. This fact is irrelevant though really, all I want to do is develop a function that will turn a row (or multiple rows) into a series of text inputs containing the data in the table (or empty if no data in cell).

I can't find any examples of people explicitly doing this, so I wondered what people here think is the best way to find a solution.

解决方案

Iterate over the table cells in the rows, and replace the contents with text inputs:

function editRow(row) {
    $('td',row).each(function() {
         $(this).html('<input type="text" value="' + $(this).html() + '" />');
    });
}

You need to pass the relevant row/rows into the function obviously.

这篇关于jQuery - 内联编辑表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆