Home > Web Front-end > JS Tutorial > 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.

巴扎黑
Release: 2017-07-24 15:07:13
Original
2433 people have browsed it

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>'
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template