我在这里缺少什么?我正在尝试在加载页面时从href中删除“jp-playlist-current”类。当这个页面加载时,我不想要任何'当前'样式。我只想在用户点击链接时显示“当前”。
不幸的是,由于这个代码是动态填充的,我不能给出类的静态视图。相反,请查看以下链接发布的屏幕截图:
http://dixiedevils.com/code.jpg
以下是该页面的完整代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Untitled</title>
<script type="text/javascript">
$(document).ready(function(){
$('div.jp-type-playlist div.jp-playlist li.jp-playlist-current a').removeClass('jp-playlist-current');
//$('div.jp-type-playlist div.jp-playlist li').removeClass('jp-playlist-current');
});
</script>
</head>
<body>
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jp_container_1" class="jp-audio">
<div class="jp-type-playlist">
<div class="jp-playlist">
<ul>
<!-- below here is where the dynamic JQ content is placed: -->
<li></li>
</ul>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
$("#jp_container_1 .jp-type-playlist .jp-playlist li").find('a').each(function(){
$(this).removeClass('jp-playlist-current');
});
答案 1 :(得分:0)
使用JPlayer时,应使用以下FINAL CODE来完成此任务:
......就在之后:
swfPath: "../js",
supplied: "ogg, mp3, m4a",
wmode: "window",
...添加:
ready : function () {
$('div.jp-type-playlist div.jp-playlist li.jp-playlist-current a').removeClass('jp-playlist-current');
$('div.jp-type-playlist div.jp-playlist li').removeClass('jp-playlist-current');
$('div.jp-type-playlist div.jp-playlist li').click(function () {
$('div.jp-type-playlist div.jp-playlist li:first').addClass('jp-playlist-current');
$('div.jp-type-playlist div.jp-playlist li.jp-playlist-current a').addClass('jp-playlist-current');
});
}
这将删除“当前”样式,然后在用户点击链接时将其添加回来。