繁体   English   中英

jQuery,数据表转换单元

[英]jQuery , datatables converting cells

我使用jquery(www.datatables.net)的DataTables插件。 如何像这样转换细胞

name www
n1   w1
n2   w2
n3   w3
name www

成为

name www
n1   <a href="w1">w1</a>
n2   <a href="w2">w2</a>
n3   <a href="w3">w3</a>
name www

在jquery中安装代码在这里:

$(document).ready(function() {
   $('#example').dataTable();
   $('#example').convertCell(setCell("<a href="getCell()">getCell()</a>"));//How to put it better?
});

和html代码是

<div id="dynamic">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
        <tr>
            <th width="15%">Name</th>
            <th width="15%">Www</th>
        </tr>
    </thead>
    <tbody></tbody>
</table>
</div>

问候:数据表中的初学者

我不确定插件,但是您可以使用:

$('.example').each(function(){
    $(this).wrap(function() {
        return '<a href="' + $(this).text() + '" />';
    });
});

将使用.example类将每个元素包装在指向每个文本的链接中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM