如果我想单击“ .img”类,那么div class="hide pane pane_right"将显示出来而不会影响其他类。这是我的代码
<ul class="admin-list">
<li>
<!--IOS Start-->
<div class="wrapper">
<div class="pane pane_left" style="display:none;">
<a class="img ios-delete icon-minus" href="#"></a>
</div>
<div class="hide pane pane_right">
<button class="ios-buttons btn btn-danger" href="#">delete</button>
</div>
<div class="pane pane_center">
<div class="pane__content">
<a href="#">[module]_setup_mysql.sql</a>
</div>
</div>
</div>
<!--IOS End-->
</li>
<li>
<!--IOS Start-->
<div class="wrapper">
<div class="pane pane_left" style="display:none;">
<a class="img ios-delete icon-minus" href="#"></a>
</div>
<div class="hide pane pane_right">
<button class="ios-buttons btn btn-danger" href="#">delete</button>
</div>
<div class="pane pane_center">
<div class="pane__content">
<a href="#">labels_en.po</a>
</div>
</div>
</div>
<!--IOS End-->
</li>
<li>
<!--IOS Start-->
<div class="wrapper">
<div class="pane pane_left" style="display:none;">
<a class="img ios-delete icon-minus" href="#"></a>
</div>
<div class="hide pane pane_right">
<button class="ios-buttons btn btn-danger" href="#">delete</button>
</div>
<div class="pane pane_center">
<div class="pane__content">
<a href="#">labels_zh-hans.po</a>
</div>
</div>
</div>
<!--IOS End-->
</li>
<li>
<!--IOS Start-->
<div class="wrapper">
<div class="pane pane_left" style="display:none;">
<a class="img ios-delete icon-minus" href="#"></a>
</div>
<div class="hide pane pane_right">
<button class="ios-buttons btn btn-danger" href="#">delete</button>
</div>
<div class="pane pane_center">
<div class="pane__content">
<a href="#">labels_zhhans.po</a>
</div>
</div>
</div>
<!--IOS End-->
</li>
</ul>
这是我的jQuery
//create an array to store the header id's
tableTitle = new Array();
//iterate through each h2 header element
$('.img').each( function(index) {
//store each h2 id in the array
tableTitle[index] = $(this).attr('id');
});
$(document).ready(function(){
//when user clicks on a header
$(".img").click(
function(){
//create a loop to close all of the paragraphs after user click
for (var i=0; i<3; i++) {
$('#'+tableTitle[i]).find(".pane_right").hide();
}
$(".wrapper").ready(function(){
//check the css of the paragraph associated with the clicked header
if($(this).find(".pane_right").css('display') == 'none'){
//if display is set to none in css, show the paragraph
$(this).find(".pane_right").show();
$(this).width('56%');
}else{
//if the display is not set to none, hide the paragraph
$(this).find(".pane_right").hide();
}
});
}
);
});