简体   繁体   中英

jQuery , datatables converting cells

I use a DataTables plugin of jquery (www.datatables.net). How to convert cells like

name www
n1   w1
n2   w2
n3   w3
name www

becames to

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

Installing code in jquery is here:

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

and html code is a

<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>

Regards: beginner in datatables

I'm not sure about the plugin, but you could use:

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

Would wrap each element with the class .example in a link pointing to the text of each.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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