在下面的javascript/html中,我可以引用div.answer但是如何引用div#flashcard-001.answer?
HTML:
<div id="flashcard-001" class="flashcard">
<div class="question">What color is the sky?</div>
<div class="answer">blue</div>
<button class="show">Show</button>
<button class="hide">Hide</button>
</div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
//run when page is loaded
google.setOnLoadCallback(function() {
$("div.answer").hide(); //WORKS
$("div#flashcard-001.answer").hide(); //DOES NOT WORK
$("button.show").bind("click", function(e) {
$("div.answer").show();
});
$("button.hide").bind("click", function(e) {
$("div.answer").hide();
});
});
Run Code Online (Sandbox Code Playgroud)
Mau*_*fer 10
你错过了一个空间:
$("div#flashcard-001 .answer").hide();
Run Code Online (Sandbox Code Playgroud)