1

我使用 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>

问候:数据表初学者

4

1 回答 1

0

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

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

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

于 2012-12-29T12:20:12.153 回答