Вместо .ta{ height:100px; } мне надо max-height. что надо изменить в js
|
.css({'max-height' : (h < max ? max : min)+'px'})
как и где это написать в js ? |
Samsam,
непонимаю вас. |
Samsam,
<style type="text/css">
.ta{
max-height:100px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<meta charset="utf-8">
<script>
jQuery(function($) {
var min = 100;
$(".ta").each(function(indx, el) {
var b = $(el),
max = el.scrollHeight,
a = b.next(".read-next");
if (max <= 100) a.hide();
else a.on("click", function(event) {
var h = b.height();
b.css({'max-height' : (h < max ? max : min)+'px'});
$(this).text(h < max ? "Svernut" : "OPen all");
return false
})
})
});
</script>
<div style="height:100%">
<div class="ta" style="overflow:hidden">
text<br>text<br>text<br>texttexttexttext<br>text<br>text<br>texttexttext<br>text<br>text<br>texttext<br>text<br>text<br>
</div><a class="read-next" href="#">OPen all</a>
</div>
|
Спасибо !! Именно то что я хотел !
|
Рони, ещё раз извиняюсь. Этот код работает, но как его задействовать в нескольких блоках
например <div class=ta>где Height = 90</div> <div class=ta>где Height = 120</div> <div class=ta>где Height = 233</div> <div class=ta>где Height = 50</div> как сделать что бы Open All выходила имена в том блоке где height>100px и при нажатие на ней этот блок раскрывался полностью. Спасибо |
Samsam,
а разве код выше этого не делает? |
| Часовой пояс GMT +3, время: 11:13. |