tailieunhanh - Học JavaScript qua ví dụ part 78

Không phô trương JavaScript Trong Chương 1 chúng ta bắt đầu nói chuyện về ba lớp tạo nên một trang web hoàn chỉnh: 1. Các nội dung hoặc lớp cấu trúc bao gồm các đánh dấu HTML / XML. 2. Các lớp phong cách hoặc trình bày bao gồm các tấm phong cách CSS. 3. Lớp hành vi bao gồm JavaScript | 682 Chapter 15 The W3C DOM and JavaScript EXPLANATION continued 10 By using the id of the target we get the value of the unique id that was assigned to the object where the event occurred. The first div container is defined with an id name first . The className property defines the class for this object. When the mouse rolls over this div it will turn red . 11 The function unColorText is triggered when the mouse moves over the text in one of the divs. This function works like the ColorText function but turns the text black when the mouse moves over the text rather than coloring it. It also changes the font size. The results are shown in Figure . 12 The three div containers are set up and positioned for the document. Figure Before the mouse rolls over the first div block top left after the mouse has left all three containers right . The font has changed in size and color for each div. Roll over me and then me and me too. Unobtrusive JavaScript In Chapter 1 we started talking about the three layers that make up a complete Web page 1. The content or structural layer consisting of the HTML XML markup. 2. The style or presentation layer consisting of the CSS style sheets. 3. The behavior layer consisting of JavaScript. From the Library of Unobtrusive JavaScript 683 Although there is often a blurred line among these layers the concept of separating content structure and style from behavior has become the goal for many developers building accessible and yet easy-to-maintain Web sites. The idea of keeping JavaScript completely separate from the other two layers is commonly called unobtrusive JavaScript. Developers have been keeping the structure and style of the document separate by placing the HTML XML in one file and the CSS styles in a separate file making it easy to change the layout throughout a Web page simply by changing the style sheet. Next comes JavaScript. Because JavaScript functions can be placed in separate files the goal .

TỪ KHÓA LIÊN QUAN