【发布时间】:2013-09-19 13:50:40
【问题描述】:
我在有重复部分的 CMS 中使用这段代码。在本节中,我可以添加一个将重复的值。但我希望最后一个重复的项目被去掉逗号。有人可以建议如何从最后一个重复的项目中删除逗号。提前非常感谢!
<script type="text/javascript">
$("#gallery").click(function(e){
e.preventDefault();
$.swipebox([
// begin repeating area/section - in this example 4 items are repeated
{href:'[%MEDIA_URL%]', title:'[%TITLE%]'},
{href:'[%MEDIA_URL%]', title:'[%TITLE%]'},
{href:'[%MEDIA_URL%]', title:'[%TITLE%]'},
{href:'[%MEDIA_URL%]', title:'[%TITLE%]'}, //this comma needs to be removed
// end repeating area/section
]);
//some code here to remove the last comma from the array ???
});
</script>
【问题讨论】:
-
生成重复项的代码在哪里?那就是您需要删除逗号的地方...
-
这是固定的,无法访问。所以需要在上述函数中去掉逗号。