JQuery chess board implementation code

Source: Internet
Author: User

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 that we have to use div + css.

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 is troublesome to bind a listener to the chess part div. To determine whether a chess part div is used, I have to rely on the-B and-w Suffixes in the class name to determine whether it is used. 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

Package

Content from: http://buhutuu.cn /? P = 783

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.