mod geek mod geek - 5 months ago 3x
Javascript Question

How To compare the Value Of The Div In jQuery

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


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


myDivObj = $('#myBox').text();
if(myDivObj == e)
alert("Wow !!");
alert("try Again !");


if (myDivObj == e) {

should be

if (myDivObj == $(e).text()) {

since e is the p.turn HTML-element

jsFiddle example