我想用另一个使用a href
链接和jquery的div来代替它。这是我的设置。
<div id="parent">
<div class="child1">Child 1 Contents</div>
<div class="child2">Child 2 Contents</div>
</div>
<div id="replacepagelinks">
<a href="#1">Replace Child 1 with Child 2</a>
<a href="#2">Replace Child 2 with Child 1</a>
</div>
我也希望<a href=#1"></a>
在被选中时消失,<a href="#2"></a>
出现,如果可能的话,反之亦然?
发布于 2012-10-17 15:21:52
如果要根据单击的元素隐藏内容,可以尝试以下方法:
$(document).ready(function(){
$('#replacepagelinks a').click(function(){
$(this).hide().siblings().show()
var w = this.hash.replace('#', '');
$('#parent div.child'+w).show().siblings().hide()
})
})
https://stackoverflow.com/questions/12929040
复制相似问题