How to pass or retrieve last selected div tag id (got through onclick function), in another onclick function using Jquery..?
<p>I pointed out what i need: (Need help for point 2 &amp; 3)</p>

<ol>
<li>I get the last selected div tag id in onclick function. (solved)</li>
<li>While click Flip X option (this is another onclick function), i need to retrieve last selected div tag id.   </li>
<li>Then in if loop i need to check div with last selected id has class front or not..?</li>
</ol>

<p>Thanks in Advance....</p>

<pre><code>$(document).ready(function()
{
var lastClickedID;

$('.ClickMe').on('click',function()
{
     lastselectedID = $(this).prop('id');
    // alert($(this).prop('id'));
}); 

$('#x').on('click',function()
{         
    if($('div').prop('id',lastselectedID).hasClass('back'))  /* Check img tag with last selected id has class 'back' exist or not */
    {
        $("img").removeClass("back").addClass("front");
    }
    else
    {
        $("img").removeClass("front").addClass("back");
    }
});
});
</code></pre>

<p>My code in <a href="https://jsfiddle.net/arunvalaven/eajdo91a/1/" rel="nofollow">Jsfiddle</a>..!</p>