我使用jquery的DataTables插件(www.datatables.net)。如何转换单元格,例如
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
类将每个元素包装在指向每个元素文本的链接中。
关于javascript - jQuery,数据表转换单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14081431/