2015年07月的文章
第2页
You may want to ask what "thisSquare" here means. A good question! You know, typically, a BINGO game is played on a 5 rows * 5 columns layout (therefore there are 25 cells in total). The above code is aimed to fetch the information that which cell is clicked by the mouse (so you now know "thisSquare" refers to the currently clicked cell). However, the meaning of "thisSquare" is not my concern. I paid much attention to the contents after the equality sign, i.e. "evt.target" and "window.event.srcElement".
The above small code snippet is very simple, but with some problems and drawbacks:
- Because the second image is downloaded from the server at the time the user rools over the first image, there can be a perceptible delay before the second image replaces the first one, especially for people browsing your site with a slower connection.
- Using this method causes an error message in ancient browsers, such as Netscape 2.0 or earlier, Internet Explorer 3.0 or earlier, or the America Online 2.7 browser. Since there are so few of these vintage browsers still in use, it's not much of a problem these days.
Operators are the symbols used to work with variables. Operators in JavaScript, as in PHP, can involve mathematics, changes to strings, and comparison and logcal operations (and, or, etc.).
In JavaScript, a piece of information is a value. There are different kinds of values. The kind you're most familiar with are numbers. A string value is characters - such as a word or words - enclosed in quotes.
Events are actions that the user preforms while visiting your page. Submitting a form and moving a mouse over an image are two examples of events. JavaScript deals with events using commands called event handlers. An action by the user on the page triggers an event handler in your script. Some common JavaScript event handlers are listed in this post.
While reading JavaScript codes, you may find "?" operator in a high frequency.
(condition) ? truePart : falsePart;
is rough equivalent of:
if (condition) {
truePart;
}
else {
falsePart;
}
网页中16种基本颜色分别是:水绿色、黑色、蓝色、紫红色、灰色、绿色、浅绿色、褐色、深蓝色、橄榄色、紫色、红色、银色、深青色、白色和黄色。
临江仙(杨慎)
滚滚长江东逝水,浪花淘尽英雄。
是非成败砖头空。
青山依旧在,几度夕阳红。
白发渔樵江渚上,惯看秋月春风。
一壶浊酒喜相逢。
古今多少事,都付笑谈中。