我想显示/隐藏与其子元素中的类相关的父元素。这就是我想要的。
<p><a href="<?php echo site_url('mp3/coins.mp3');?>" title="hello" class="sm2_button" id="song1">play</a> Dear Yesterdays </p>
<p><a href="<?php echo site_url('mp3/fancy-beer-bottle-pop.mp3');?>" title="hello" class="sm2_button" id="song2">play</a> song 2</p>
<p><a href="<?php echo site_url('mp3/coins.mp3');?>" title="hello" class="sm2_button" id="song1">play</a> Dear Yesterdays </p>
<p><a href="<?php echo site_url('mp3/fancy-beer-bottle-pop.mp3');?>" title="hello" class="sm2_button" id="song2">play</a> song 2</p>
<script>
$(document).ready(function(){
$('.play p').hide();
$('.play p:first').show();
$('.play p a').each(function(){
var attr = $(this).attr('class');
var cls = attr.split(' ');
if(cls[1]=='sm2_playing' || cls[1]=='sm2_paused')
{
// display none to all .play p tags except the one with those classes sm2_playing or sm2_paused
}
});
});
</script>
请帮我。我正在使用soundmanager2。我想一首又一首地播放歌曲,而只显示正在播放的歌曲。