Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery tick-tac-toe clearboard issue
    primarykey
    data
    text
    <p>i have tried to make tictactoe using jQuery its working fine but issue is when clear board one of the </p> <p>field fill automatically,is there any way to prevent it after clear board. </p> <p>here is my code.Just need to prevent element filled automatically after board is cleared</p> <pre><code> &lt;script&gt; jQuery(document).ready(function(){ function clearboard(){ alert('you win'); jQuery('ul li').text(''); } jQuery('li').click(function(){ // alert(jQuery(this).attr('class')); if(!jQuery(this).text()){ jQuery(this).text('o'); } jQuery("li").toggle( function () { var temp ='x'; jQuery(this).text(temp); }, function () { var temp ='o'; jQuery(this).text(temp); } ); if( (jQuery('.f1').text()=='x'&amp;&amp; jQuery('.f5').text()=='x'&amp;&amp; jQuery('.f9').text()=='x')||(jQuery('.f1').text()=='o'&amp;&amp; jQuery('.f5').text()=='o'&amp;&amp; jQuery('.f9').text()=='o')){ clearboard(); } else if( (jQuery('.f1').text()=='x'&amp;&amp; jQuery('.f2').text()=='x'&amp;&amp; jQuery('.f3').text()=='x')||(jQuery('.f1').text()=='o'&amp;&amp; jQuery('.f2').text()=='o'&amp;&amp; jQuery('.f3').text()=='o')) { clearboard() } else if( (jQuery('.f4').text()=='x'&amp;&amp; jQuery('.f5').text()=='x'&amp;&amp; jQuery('.f6').text()=='x')||(jQuery('.f4').text()=='o'&amp;&amp; jQuery('.f5').text()=='o'&amp;&amp; jQuery('.f6').text()=='o')) { clearboard(); } else if( (jQuery('.f7').text()=='x'&amp;&amp; jQuery('.f8').text()=='x'&amp;&amp; jQuery('.f9').text()=='x')||(jQuery('.f7').text()=='o'&amp;&amp; jQuery('.f8').text()=='o'&amp;&amp; jQuery('.f9').text()=='o')) { clearboard(); } else if( (jQuery('.f1').text()=='x'&amp;&amp; jQuery('.f4').text()=='x'&amp;&amp; jQuery('.f7').text()=='x')||(jQuery('.f1').text()=='o'&amp;&amp; jQuery('.f4').text()=='o'&amp;&amp; jQuery('.f7').text()=='o')) { clearboard(); } else if( (jQuery('.f2').text()=='x'&amp;&amp; jQuery('.f5').text()=='x'&amp;&amp; jQuery('.f8').text()=='x')||(jQuery('.f2').text()=='o'&amp;&amp; jQuery('.f5').text()=='o'&amp;&amp; jQuery('.f8').text()=='o')) { alert('you win'); clearboard(); } else if( (jQuery('.f3').text()=='x'&amp;&amp; jQuery('.f6').text()=='x'&amp;&amp; jQuery('.f9').text()=='x')||(jQuery('.f3').text()=='o'&amp;&amp; jQuery('.f6').text()=='o'&amp;&amp; jQuery('.f9').text()=='o')) { clearboard(); } else if( (jQuery('.f3').text()=='x'&amp;&amp; jQuery('.f5').text()=='x'&amp;&amp; jQuery('.f7').text()=='x')||(jQuery('.f3').text()=='o'&amp;&amp; jQuery('.f5').text()=='o'&amp;&amp; jQuery('.f7').text()=='o')) { clearboard(); } }) &lt;/script&gt; &lt;style&gt; ul { float: left; max-width: 247px; } li { border: 1px solid; float: left; font-size: 44px; height: 60px; list-style: none outside none; text-align: center; vertical-align: top; width: 60px; } &lt;/style&gt; &lt;body&gt; &lt;ul&gt; &lt;li class="f1"&gt;&lt;/li&gt; &lt;li class="f2"&gt;&lt;/li&gt; &lt;li class="f3"&gt;&lt;/li&gt; &lt;li class="f4"&gt;&lt;/li&gt; &lt;li class="f5"&gt;&lt;/li&gt; &lt;li class="f6"&gt;&lt;/li&gt; &lt;li class="f7"&gt;&lt;/li&gt; &lt;li class="f8"&gt;&lt;/li&gt; &lt;li class="f9"&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>her is my fiddle</p> <p><a href="http://jsfiddle.net/cVN7j/" rel="nofollow">http://jsfiddle.net/cVN7j/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload