Home  >  Article  >  Web Front-end  >  Instructions on how to use DataTables to obtain row data of specified elements.

Instructions on how to use DataTables to obtain row data of specified elements.

巴扎黑
巴扎黑Original
2017-07-24 15:07:132419browse

Method 1:

Use jquey to get, var row = $('.edit').parent().parent();

Disadvantage: can only get things on the dom , cannot obtain non-rendered data

Method 2:

First bind the line number to the element

$('#example'"columns""data":"name", "orderable": , "searchable": ,"render" :   '<button id="btnEdit" data-rowindex="&#39;+meta.row+&#39;">编辑</button>'

Then Get the row number based on the element

var rowIndex = $('#btnEdit').attr('data-rowindex');

Finally get the data

$('# userTable').DataTable().rows(rowIndex).data()[0];

The above is the detailed content of Instructions on how to use DataTables to obtain row data of specified elements.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn