我有这段代码:
(我想获取标签并将它们插入到将写入 HTML 页面的 JS 数组中,但我无法正确获取标签,您能告诉我有什么问题吗,或者帮我这样做,我已经搜索了很多解决方案,但没有一个在这里工作,标签用逗号分隔)
ASP.NET
private void Play(List<string> arraySrc, List<string> arrayTitle, List<string> arrayImage, List<string> arrayTags)
{
...
string[] tags = arrayTags.ToArray();
string[] split;
foreach (string item in tags)
{
if (item.IndexOf(',') != -1)
{
split = item.Split(',');
foreach (string s in split)
{
ClientScript.RegisterArrayDeclaration("arrayTags", String.Concat("\"<span class=label>", s, "</span>\" "));
}
}
ClientScript.RegisterArrayDeclaration("arrayTags", String.Concat("\"<span class=label>", item, "</span>\" "));
}
}
JS
function playList () {
disabled();
$("#img").attr("src", "image/no-music.png");
for (var i = 0; i < arraySrc.length; i++) {
$("#tab1 ul").append("<li>" + (i + 1) + ". <a href='javascript:loadMusic(\"" + arraySrc[i] + "\", \"" + arrayTitle[i] + "\", \"" + arrayImage[i] + "\", \"" + arrayTags[i] + "\"); selected(" + i + ");'>" + arrayTitle[i] + "</a></li>");
};
}
function loadMusic (musica, title, image, tags) {
enabled();
var audio = $("#player");
$("#tags").empty();
$("#tags").append(tags);
$("#player").attr("src", musica);
$("#title").text(title);
$("#img").attr("src", image);
$("#tags span").addClass("label-info");
/****************/
audio[0].pause();
audio[0].load(); //suspends and restores all audio element
audio[0].play();
}