Some time ago, in order to get familiar with the various starting stages of chess, I wrote a very simple chess board (I could not find the ready-made one ). I didn't think there was anything at the time. Let's look back today and I think it's a bit interesting. I'll give it to you for identification.
First, we need to arrange the chess pieces. There is no doubt p + css is used.
For specific code, see Jquery's chess board (view the source code ).
At first, I wrote classes for each piece. In fact, this is a silly behavior. First, css code is redundant. Second, it will be troublesome to bind a listener to the chess piece p. To determine whether it is a chess piece p, I have to rely on the-B and-w Suffixes in the class name to determine whether it is a chess piece. However, if we extract the common attributes of the pawns and create a class qizi, we can solve both of these problems.
In the code, I did not specifically remove the previous code. You can see it in the annotated code. I have to write a method on both sides so that both the black and white flags can be moved. You see, this is the consequence of not doing enough abstraction.
The next step is to implement drag. For more information, see
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service