如何使用jquery刪除最後一個逗號','。下面是我的幻燈片圖像後臺代碼的jQuery,PHP代碼將在JavaScript中循環圖像的URL,意味着用戶可以在管理員改變形象:如何使用jquery刪除最後一個逗號','
navigation : 1, //Slideshow controls on/off
thumbnail_navigation : 1, //Thumbnail navigation
slide_counter : 1, //Display slide numbers
slide_captions : 1, //Slide caption (Pull from "title" in slides array)
slides : [ //Slideshow Images
<?php // this will looping image background custom - xx_rusly_xx
$images = getFieldOrder('background_slideshow_image');
foreach($images as $image){
echo "{image : '";
echo get('background_slideshow_image',1,$image);
echo "'},";
}
?>
]
});
});
</script>
如果你發現我把一些PHP代碼迴路圖像URL
<?php // this will looping image background custom - xx_rusly_xx
$images = getFieldOrder('background_slideshow_image');
foreach($images as $image){
echo "{image : '";
echo get('background_slideshow_image',1,$image);
echo "'},";
}
?>
和瀏覽器將用PHP生成Javascript這樣的:
//Components
navigation : 1, //Slideshow controls on/off
thumbnail_navigation : 1, //Thumbnail navigation
slide_counter : 1, //Display slide numbers
slide_captions : 1, //Slide caption (Pull from "title" in slides array)
slides : [ //Slideshow Images
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/1.jpg'},
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/2.jpg'},
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/3.jpg'},
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/4.jpg'}, ]
});
});
</script>
,問題是如何在最後一行刪除逗號,因爲Internet Explorer,這將不只是IR運行去掉最後一個逗號。
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/4.jpg'},
這裏是完整的代碼 - >http://pastebin.com/c1A7ZKGr
感謝您的幫助。
呈現的html看起來像'view source'是什麼? –
http://iconcept-project.com/dev/gd/ – ruslyrossi
(Offtopic)P.S.嘗試優化圖像大小。加載時間過長 –