I have a list of divs, which what I want to achieve is when user clicks on column , it gets the data square assigns it to variable from, and when again click on another column it assigns the data to variable to.
I do know how to send values to php by ajax, just the fact of getting the variables from and to is the issue. this is a board game, which i need to send two variable from and to , to server
<div class="column" data-square="4-4">
<div class="lol">p</div>
</div>
<div class="column" data-square="4-5">
<div class="lol">p</div>
</div>
<div class="column" data-square="4-6">
<div class="lol">p</div>
</div>
$( ".column" ).click(function(){
var from = $(this).data('square');
var to = $(this).data('square');
alert(to);
alert(from);
});
there are lets say 10 divs //10 of these with different value of data-square p where user clicks on one of them , it should store the data square value in variable from, when user clicks again on another div it should store the variable in variable to