这段代码不会产生任何错误:
//if the image has tags
if(data.photo.tags.tag != '') {
//create an empty array to contain all the tags
var tagsArr = new Array();
//for each tag, run this function
$.each(data.photo.tags.tag, function(j, item){
//push each tag into the empty 'tagsArr' created above
tagsArr.push('<a href="http://www.flickr.com/photos/tags/' + item._content + '">' + item.raw + '</a>');
});
//turn the tags array into a string variable
//var tags = tagsArr.join(' ');
}
但是如果我将标签数组推送行更改为:
//push each tag into the empty 'tagsArr' created above
tagsArr.push( + item.raw + );
});
然后我在分号处遇到语法错误。我想做的是删除标记的链接并只返回原始链接。
想法和感谢!
最佳答案
如果您只想输出 item.raw
值,请执行以下操作:
tagsArr.push(item.raw);
关于javascript - 为什么会出现分号语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5057978/