ここでjsfiddleを参照してください
「続きを読む」リンクをスライドダウンさせ、クリックすると非表示のコンテンツを表示しようとしていますが、クリック機能が正しく登録されていないようです。私は明らかに間違ったことをしましたか?
基本的なhtmlレイアウト
<div id="wrapper">
<div id="aHidden">some long text here</div> <!--defaulted hidden with css-->
<div id="aBtn" class="bio-readMore">read more...</div>
</div>
これを行うために使用しようとしているjQueryは次のとおりです。
$(document).ready(function() {
$("div").each(function(idx) {
if ($(this).hasClass('bio-readMore')) {
var thename = this.id.replace("Btn", "Hidden");
var sel = "#" + thename;
$(sel).click(function() {
alert("running click for element with value " + this.id);
if ($(this).is(":hidden")) {
$(this).slideDown("slow");
} else {
$(this).slideUp();
}
});
}
});
});