基本的には「もっと見る」タイプのものを作っています。私が取り組んできたことを説明する小さな段落と、段落の最後にあるボタンがあります。I (実際にはボタン スタイルのリンクです)。ボタンが押されると、div が 400px に拡張され、余分なテキストが .html(); で追加されます。しかし、「ビューを減らす」ボタンを押して小さな段落と 200px の div に戻ると、何も起こりません。
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;
}
});