我正在尝试创建一个onclick
元素,在单击播放按钮时播放歌曲。我设置它的方式非常适用于不包含撇号的歌曲,但对于那些没有撇号的歌曲,这首歌不会播放。
这是网站,因此您可以测试:https://www.unearthapp.io/Home/New(将鼠标悬停在一首歌曲上点击播放按钮)
不起作用的歌是“不要说你爱”#34;这里是html中相应的代码:
这里是html
<a href="@Url.Action("Index", "Album", new { ID = item.Album.AlbumID })">@item.Title</a><span class="feat-artists">@item.Artist</span>
和相应的javascript
function playPauseClick(_songID, title, artist, url, imageURL)
{
songID = _songID;
var song =
{
songID: songID,
title: ((title != null && title != "" && title != "null") ? title : ''),
artist: ((artist != null && artist != "" && artist != "null") ? artist : ''),
file: url,
imageURL: (imageURL != "" ? imageURL : SITEROOT_ABSOLUTE + "/resources/images/album_ph.jpg"),
howl: null
}
if(player == null)
{
player = new Player([ song ]);
}
else
{
player.playlist.push(song);
}
playPauseBtn = $("#playPauseBtn" + songID);
resetPlayPauseBtns();
if(playPauseBtn.hasClass("ion-ios-play") && !playPauseBtn.hasClass("resumesong"))
{
player.skipTo(player.playlist.length - 1);
}
else
{
togglePlayPauseBtn();
}
return;
}
答案 0 :(得分:1)
这个怎么样?
var str = "Don't Say You Love";
var res = str.replace("'", "\'");
答案 1 :(得分:-1)
发现您的错误。
(function(event){playPauseClick('82', 'Don't Say You Love', 'SITA', 'https://ucarecdn.com/20bd363d-b830-4676-87f0-7734db3752e4/', 'https://ucarecdn.com/c27c2c47-1c5e-46fa-ab13-feb5d4a7c6a6/');
})
这个问题是这个
'Don't Say You Love'
使用Don\'t
或"Don't Say You Love"
这里的问题是你在Don&#t; t