JSFiddle - React, Tailwind, and code Playground
by bobbyrne01
HTML
<label id="square"></label>
<table>
<tr>
<td class="evenSquare">
<div id="pawnBlack0"data-row="1" data-col="0" data-captured="false">
<img src="images/pawnBlack.png" id="pawnBlack0"width="60px"></img>
</div>
</td>
</tr>
</table>
JavaScript
function BasePiece(x, y, captured, team){
this.x = x;
this.y = y;
this.captured = captured;
}
BasePiece.prototype.toString= function(){
return 'BasePiece at ' + this.x + ', ' + this.y + ', ' + this.captured;
};
$(document).ready(function () {
var piece = new BasePiece($("#pawnBlack0").attr('data-row'), $("#pawnBlack0").attr('data-col'), $("#pawnBlack0").attr('data-captured'));
$("#square").text(piece.toString());
});