Ich versuche, einen bestimmten Text erscheinen zu lassen, wenn Sie auf ein Element klicken, wenn die Schaltfläche einen bestimmten Text hat. Derselbe Text der ersten if-Anweisung wird jedoch weiterhin angezeigt.überprüfen Schaltfläche Wert jquery
ist dies die Taste:
<button class="game-button">Start spel</button>
Das sind die Tabellenelemente sind:
<div id="speelveld">
<table border="0">
<tr>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
</tr>
<tr>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
</tr>
<tr>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
</tr>
</table>
</div>
und dies ist der JavaScript-Code:
$(".game-button").click(function(){
$(".game-button").html("Reset spel");
});
if ($(".game-button").val() == "Start spel") {
$("#speelveld tr td").click(function() {
alert("Je kunt nog niet beginnen");
});
} else {
$("#speelveld tr td").click(function() {
alert("hoi");
});
}
meine Frage ist: Wie kann ich Eine bestimmte Warnung erscheint, wenn die Taste einen bestimmten Text hat
Du Bindungsereignis in der 'if'. Es wird nur das Ereignis innerhalb von 'if' registriert –