我找到了一个非常适合我工作的代码。我想在jquery 8中设置div height auto no line。请看链接。
http://jsfiddle.net/alexis_tondelier/Gf2dv/
HTML
<div class="item">
<div class="item-overlay"></div>
</div>
<div class="item">
<div class="item-overlay"></div>
</div>
jquery的
$(document).ready(function () {
var $active,
togglerSelector = '.item',
toggledSelector = '.item-overlay',
$items = $(togglerSelector),
animationDuration = 300,
activeClassName = 'active',
activeStyle = {height: 300},
notActiveStyle = {height: 0},
hideActive = function() {
$active && $active
.stop()
.animate(notActiveStyle, function() {
$(this).removeClass(activeClassName).hide();
});
$active = void 0;
},
showActive = function($element) {
$element && ($active = $element)
.stop()
.show()
.animate(activeStyle)
.addClass(activeClassName)
};
$items.on('click', function(event) {
var $this = $(this),
$overlay = $this.children(toggledSelector),
theSame = $overlay.is($active);
hideActive();
theSame || showActive($overlay);
});
$(this).on('click', function(event) {
var $target = $(event.target),
isOutClick = !$target.closest(togglerSelector).length;
isOutClick && hideActive();
});
});
...谢谢