林很新的使用下面的代码的jQuery但即时通讯:有没有办法在jquery函数中剪辑一个字符串?
var lineParts = [];
$.each(chartData, function(k,v){
barParts.push({
label: k,
value: v
});
});
如何夹持件K字符串的第3个字符?例如,我想积极成为Pos。我试过用这个但没有快乐:
var lineParts = [];
$.each(chartData, function(k,v){
k = k.substring(0,3);
lineParts.push({
label: k,
value: v
});
});
开始什么是你用K = k.substring得到错误(0,3); ? – Tivie
重复的:https://stackoverflow.com/questions/1199352/smart-way-to-shorten-long-strings-with-javascript –
我不认为它是一个重复的答案,因为OP已经做了正确的步骤,唯一的错误在函数参数$ .each –