我有一个功能,给了我一些数据输出:如何拆分逗号分隔变量?
$(document).ready(function() {
var table = $('#myTable').DataTable();
table.MakeCellsEditable({
"onUpdate": myCallbackFunction
});
});
function myCallbackFunction(updatedCell, updatedRow, oldValue,row) {
console.log("The values for each cell in that row are: " + updatedRow.data());
}
我的控制台输出为:The values for each cell in that row are: 2,Alan,Dirt,[email protected]
我现在想输出我的函数里面只有逗号分隔的列表的第一个值。所以,我把它改成如下:
function myCallbackFunction(updatedCell, updatedRow, oldValue,row) {
var row = updatedRow.data();
var id = row.split(",");
console.log("The first value is: " + id[0]);
}
但我得到的控制台错误现在TypeError: row.split is not a function. (In 'row.split(",")', 'row.split' is undefined)
这是什么意思?
哪个版本的jquery简称 –
@BalajiM的版本是2.2.3 – Jarla