javascript - Jquery not removing variable's Class -
i'm making chess website practice , trying assign variable element id, use variable remove class element. reason program seems crash when try this. html snipped looks this:
<td class="square light" id="1"></td>
and javascript using jquery looks this:
var firsttouch = false; var startid = 0; $('.square').click(function(){ if (firsttouch == false){ startid = $(this).attr('id'); alert(startid); firsttouch = true; } else { var startsquare = document.getelementbyid(startid); startsquare.removeclass('pawna'); firsttouch = false; } });
i wondering if has idea why isn't working. when alert on variable startsquare gives: [object htmltablecellelement] i'm guessing found element, doesn't seem want remove class unfortunately.
because getting element via pure js doesn't define startsquare
jquery object; jquery selectors...
$("#"+ startid).removeclass('pawna');
Comments
Post a Comment