我有一个小jquery show / hid脚本。我遇到的问题是它显示了所有的选民。我只是想让它显示被点击的div中的那个。
HTML
<!--row1 -->
<div class="row resource-line-item">
<div class="zone1">
<h3 class="clickable">ANDALE.TTF - True Type Font</h3>
<span class="edit-resource">Edit</span>
</div>
<div class="zone2 printer-state">
<p> Size: 4153344 <br>
Date: Tuesday, March 26, 2013 2:14:14 PM</p>
</div>
<div style="display: none;" class="edit-Box"> </div>
</div>
<!--row2 -->
<div class="row resource-line-item">
<div class="zone1">
<h3 class="clickable">ANDALE.TTF - True Type Font</h3>
<span class="edit-resource">Edit</span>
</div>
<div class="zone2 printer-state">
<p> Size: 4153344 <br>
Date: Tuesday, March 26, 2013 2:14:14 PM</p>
</div>
<div style="display: none;" class="edit-Box"> </div>
</div>
JQUERY
<script type="text/javascript">
$("#resource-list-area .edit-resource").on("click", function(event){
$(this).next(".edit-box").toggle();
//alert('hello')
});
</script>
答案 0 :(得分:4)
再次,猜测那是你的标记
$("#resource-list-area").on("click", ".edit-resource", function(event) {
$(this).closest(".row").find(".edit-Box").toggle();
});
见工作小提琴:http://jsfiddle.net/xZBje/1
答案 1 :(得分:0)
$(".edit").click(function() {
$(this).next().toggle();
});