在一個網站中,我有幾個「下拉列表」,當您按加號時變得可見。我用jQuery做了這個(見下面的代碼),但是每當按下按鈕打開時。我怎樣才能打開按鈕按下的下拉列表(沒有爲每個按鈕再次寫這個代碼)?jQuery點擊打開一個下拉框
$('main .menu').click(function() {
if($(this).hasClass('open')) {
$(this).removeClass('open');
$('main .menu').html('+');
$('main .info').slideUp();
}
else {
$(this).addClass('open');
$('main .menu').html('-');
$('main .info').slideDown();
}
});
HTML:
<div id="first">
<img src="images/flexit.jpg" alt="">
<h2>Flexit</h2>
<a href="#" class="menu">+</a>
<div class="info">
<table>
<tr>
<td>Name:</td>
<td>Flexit</td>
</tr>
<tr>
<td>Dimensions:</td>
<td>2000 x 1600 x 1900 mm</td>
</tr>
<tr>
<td>Material(s):</td>
<td>powdercoated steal, redwood</td>
</tr>
<tr>
<td>Weight:</td>
<td>43 kg</td>
</tr>
<tr>
<td>Current location:</td>
<td>Buzzkruit exhibition, Designcenter Winkelhaak Antwerp</td>
</tr>
</table>
</div>
分享您的HTML代碼。 –
HTML pleeezz ... –
@PraveenKumar添加了html! – user3071261