这是我的jsfiddle:
代码:
$('.theHider').click(function () {
$("'." + $(this).id + "'").hide();
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="cola">This will be cola</div>
<div class="cola">This will be cola</div>
<div class="birch">This will be birch</div>
<div class="cola">This will be cola</div>
<div class="cola">This will be cola</div>
<div class="orange">This will be orange</div>
<div class="birch">This will be birch</div>
<div id="cola" class="theHider">This will hide cola</div>
<div id="birch" class="theHider">This will hide birch</div>
<div id="orange" class="theHider">This will hide orange</div>
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这不起作用.
至于文件准备等等,当它阻止jsfiddle工作时我把它拿出来了.