Move Pieces
Use the move
method to make one or more moves on the board.
HTML
<chess-board style="width: 400px"></chess-board>
<button id="move1Btn">e2-e4</button>
<button id="move2Btn">d2-d4, g8-f6</button>
<button id="startPositionBtn">Start Position</button>
JavaScript
const board = document.querySelector('chess-board');
document.querySelector('#move1Btn').addEventListener('click', () => {
board.move('e2-e4');
});
document.querySelector('#move2Btn').addEventListener('click', () => {
board.move('d2-d4', 'g8-f6');
});
document.querySelector('#startPositionBtn').addEventListener('click', () => {
board.start();
});