Ich habe diese HTML, wo "5" zweimal wiederholt.Ziel mehrere Elemente mit Jquery, wenn Bedingung übereinstimmt
<ul>
<li>5</li>
<li>6</li>
<li>7</li>
<li>5</li>
</ul>
Also verwende ich click() auf "LI" Elemente.
var guess1 = "";
var guess2 = "";
var count = 0;
$("li").click(function(){
if (count < 2){
count++;
if (count === 1) {
guess1 = $(this).text();
} else{
guess2 = $(this).text();
if (guess1 === guess2) {
$(this).css("background", "red"); // Here both matching "LI" should affect. Not only one "LI"
}
}
}
});
Problem: Ich möchte, dass, wenn "guess1" === "guess2", dann beide matching "LI" (In diesem Fall LI enthält Wert "5") bg Farbe nehmen sollte.
Bitte geben Sie einen Vorschlag. Danke :)
Wow !! Super. Es funktioniert gut. :) Danke, Mann ! – Sahil