.click 内に jQuery 関数がありますが、機能しません。私はjQueryをテストしましたが、動作していますが、.click内のテストとして複数の組み合わせを試しましたが、何らかの理由で正しく動作しません. コンソールは空白で、エラーはないと表示されます。ただし、定義済みの変数が見つからないと言っています...
html:
<body>
<section id="container_header">
<header>
<nav>
<a id="home">Home</a>
<a id="about">About</a>
<a id="work">Work</a>
<a id="contact">Contact</a>
</nav>
</header>
</section>
<section id="container_content">
<div class="section" id="section-home"></div>
<div class="section" id="section-about"></div>
<div class="section" id="section-work"></div>
<div class="section" id="section-contact"></div>
</section>
CSS を使用して、空の div をレンダリングしていますが、正しく表示されます。jsの場合:
$(function(){
$(this).click(function(){
var pid = $(this).attr("id"); //console says this var is not defined???
$(this).hide(); //even this does not work???
//$("div[id^=section-]").hide(); //this works just fine???
//$(this).closest("#container_header").hide(); //not working???
//$(this).closest("body").find("#section-" + pid).show(); //no likey???
//alert("h"); //works
});
});
上記のコメントは、機能するものと機能しないものについて説明しています。それはおそらく愚かなことですが、私には見えません。はい、テスト中に、コメントを試す前にコメントを削除しています。