我有一个数组如下
["http://wallpaper-gallery.net/top/wallpapers-6.jpeg", "http://wallpaper-gallery.net/top/wallpapers-8.jpg", "http://wallpaper-gallery.net/top/wallpapers-10.jpg"]
我想在jquery中将其序列化为类似于serialize()
方法,以获得以下内容
links=http%3A%2F%2Fwallpaper-gallery.net%2Ftop%2Fwallpapers-6.jpeg%0D%0Ahttp%3A%2F%2Fwallpaper-gallery.net%2Ftop%2Fwallpapers-8.jpg%0D%0Ahttp%3A%2F%2Fwallpaper-gallery.net%2Ftop%2Fwallpapers-10.jpg
如何以高效的方式在javascript中实现这一目标
答案 0 :(得分:3)
var links = ["http://wallpaper-gallery.net/top/wallpapers-6.jpeg", "http://wallpaper-gallery.net/top/wallpapers-8.jpg", "http://wallpaper-gallery.net/top/wallpapers-10.jpg"];
console.log("links="+encodeURIComponent(links.join("\r\n")));