嗨,我正在运行一个相当简单的脚本,它在单击时显示隐藏 div 中的内容。问题是“隐藏”元素不能仅“显示”。
<script type="text/javascript">
$(function() {
$(".slidingDiv").hide();
$(".hide, .show").show().on('click', function(e) {
var elm = $(e.target).is('.show') ? $(e.target) : $(e.target).parent().prev('.show');
elm.toggle().next(".slidingDiv").slideToggle()
});
});
</script>
<style type="text/css">
.slidingDiv {
display: none;
height:200px;
width:auto;
}
</style
<div id="footer-widgets-container">
<div id="footer-widgets" class="col-full col-4"> <a href="#" class="show">Show</a>
<div class="slidingDiv">
<div class="block footer-widget-1 widget">
<div class="col1a"></div>
<div class="col3c"></div>
<div class="col2b"></div>
</div>
<div class="block footer-widget-2"></div>
<div class="block footer-widget-3"></div>
<div class="block footer-widget-4">
<div class="skype p"><a href="#"><p>Skype</p></a>
</div>
<div class="email p"><a href="#"><p>Email</p></a>
</div>
</div>
</div>
</div><a href="#" class="hide">Hide</a>
</div>