gpt4 book ai didi

javascript - 如何在另一个函数的函数中使用一个函数

转载 作者:行者123 更新时间:2023-11-30 14:22:43 24 4
gpt4 key购买 nike

我正在尝试将另一个函数中每个单词的首字母大写。

这是我正在使用的将每个单词的第一个字母转换为大写的函数。

function capital_letter(str) 
{
str = str.split(" ");

for (var i = 0, x = str.length; i < x; i++) {
str[i] = str[i][0].toUpperCase() + str[i].substr(1);
}

return str.join(" ");
}

这是我尝试使用第一个函数的第二个函数,但它不起作用。

$(document).ready(function() {
$('#list').dataTable({
"ajax":{
url :"list.php",
type: "GET",
error: function(){
$("#post_list_processing").css("display","none");
}
},
"columns": [
{ "data": function capital_letter(item) {
return item.title;
}
},
{ "data": "description" },
{ "data": "time" }
]
});
});

最佳答案

你应该只调用如下函数:

$(document).ready(function() {
$('#list').dataTable({
ajax: {
url: 'list.php',
type: 'GET',
error: function() {
$('#post_list_processing').css('display', 'none');
},
},
columns: [{
data: capital_letter(item.title);

},
{ data: 'description' },
{ data: 'time' },
],
});
});

关于javascript - 如何在另一个函数的函数中使用一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52478181/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com