Reputation: 310
I would appreciate If somebody help here! . I want to compare the value of the div from the php array using jQuery.
I have a php array
$newarray=array('cat','cap','catm','cam','catp','camp');
i have assigned a class 'turn' too all the php array members
foreach($newarray as $col){
echo "<p class='turn'>".$col."</p>";
}
Now I want to check the value of the div and compare that if value in the textbox is equal to arrays value or not.
I have given the myBox id to the div
and this is my jQuery Code
$(".wordComb").click(function(){
$(".turn").each(function(i,e){
myDivObj = $('#myBox').text();
if(myDivObj == e)
{
alert("Wow !!");
}
else{
alert("try Again !");
}
});
});
Upvotes: 1
Views: 1219
Reputation: 11796
if (myDivObj == e) {
should be
if (myDivObj == $(e).text()) {
since e
is the p.turn
HTML-element
Upvotes: 3