В основном, что я делаю, вы делаете «вид больше». У меня есть небольшой абзац текста, описывающий что-то, над чем я работал, и кнопку в конце абзаца. I (Это действительно ссылка, с стилем кнопки). Когда кнопка нажата, div расширяется до 400 пикселей, а дополнительный текст добавляется с помощью .html(); но когда я нажимаю кнопку «Показать меньше», чтобы свернуть обратно к меньшему абзацу и 200px div, ничего не происходит.Изменение размера окна JQuery с помощью кнопки
JQuery
$(document).ready(function(){
var $mottheight = $('#row-mott').height();
if ($mottheight == 300) {
$('#mott-btn-collapse').click(function(){
$('#row-mott').animate({
height:200
}, 300);
$('#mott').html('I\'ve worked on the Warren Mott High School website since September of 2011. I am one of four student webmasters that keep the website in the best condition possible. We cannot take credit for all the coding, though. This website is run by around 40 Web Design students. As Webmaster, my job is to fix, improve, and help those students learn as they go. <a href="#" id="mott-btn" class="btn btn-mini">Less info »</a>');
});
}
else if ($mottheight < 300){
$('#mott-btn').click(function(){
$('#row-mott').animate({
height:300
}, 400);
$('#mott').html('I\'ve worked on the Warren Mott High School website since September of 2011. I am one of four student webmasters that keep the website in the best condition possible. We cannot take credit for all the coding, though. This website is run by around 40 Web Design students. As Webmaster, my job is to fix, improve, and help those students learn as they go. I\'ve worked on the Warren Mott High School website since September of 2011. I am one of four student webmasters that keep the website in the best condition possible. We cannot take credit for all the coding, though. This website is run by around 40 Web Design students. As Webmaster, my job is to fix, improve, and help those students learn as they go. I\'ve worked on the Warren Mott High School website since September of 2011. I am one of four student webmasters that keep the website in the best condition possible. We cannot take credit for all the coding, though. This website is run by around 40 Web Design students. As Webmaster, my job is to fix, improve, and help those students learn as they go. <a href="#" id="mott-btn-collapse" class="btn btn-mini">Less info »</a>');
});
}
else {
return 0;
}
});
Помните, что код выполнен во время загрузки. Когда страница загружает первый оператор if, то false, поэтому привязка клика никогда не загружается. –