目前我的博客上有两篇文章。帖子的标记如下(精简了一点):
<div class="post audio" id="post_27">
<div class="subpost">
<div class="jp-jplayer">
<!-- Other unimportant code -->
</div>
</div>
</div>
<div class="post audio" id="post_26">
<div class="subpost">
<div class="jp-jplayer">
<!-- Other unimportant code -->
</div>
</div>
</div>
和 jQuery:
$(document).ready(function(){
var post_id = $(".jp-player").parents(".audio").attr("id");
$(".jp-jplayer").attr("id", "jp_" + post_id);
$("#jp_" + post_id).jPlayer({
ready: function (event) {
$(this).jPlayer("setMedia", {
m4a: "media link..."
});
},
swfPath: "/feathers/audio/jplayer",
supplied: "m4a",
cssSelectorAncestor: "#jp_container_" + post_id,
wmode: "window",
smoothPlayBar: true,
keyEnabled: true
});
});
我想知道如何使用 jQuery 将jp-jplayer DIV 的 id 设置为与其各自的音频父级相同。这已经困扰了我好几个小时了,所以非常感谢任何帮助!