我正在使用 jquery UI 的手风琴。当用户切换标签时,我需要隐藏一些图像。我尝试了几种不同的方法(http://api.jqueryui.com/accordion/#event-beforeActivate),但它不起作用:
HTML:
<div id="accordion">
<h3>
<a href="#">
<span class="menu-item">About</span>
<img id="slide1" src="/images/sliding-image_1.png"/>
</a>
</h3>
<div>
.................
</div>
<h3><a href="#">................
JS:
<script>
$( "#accordion" ).accordion({ beforeActivate: function( event, ui )
{
ui.newHeader.click(function () {
$('#slider1').remove();
}
}
});
</script>
或者另一个:
<script>
$("#accordion").accordion({
beforeActivate: function(event, ui) {
if(ui.newHeader) {
$('h3 a img').remove();
}
}
});
</script>