TAILIEUCHUNG - jQuery in Action phần 2

Tham khảo tài liệu 'jquery in action phần 2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 4 CHAPTER 1 Introducing jQuery manage but it also gives us the versatility to completely change the stylistic rendering of a page by swapping out different stylesheets. Few of us would voluntarily regress back to the days of applying style with HTML elements yet markup such as the following is still all too common button type button onclick xyz . red Click Me button We can easily see that the style of this button element including the font of its caption is not applied via the use of the font tag and other deprecated style-oriented markup but is determined by CSS rules in effect on the page. But although this declaration doesn t mix style markup with structure it does mix behavior with structure by including the JavaScript to be executed when the button is clicked as part of the markup of the button element which in this case turns some Document Object Model DOM element named xyz red upon a click of the button . For all the same reasons that it s desirable to segregate style from structure within an HTML document it s as beneficial if not more so to separate the behavior from the structure. This movement is known as Unobtrusive JavaScript and the inventors ofjQuery have focused that library on helping page authors easily achieve this separation in their pages. Unobtrusive JavaScript along with the legions of the jQuery-savvy considers any JavaScript expressions or statements embedded in the body of HTML pages either as attributes of HTML elements such as onclick or in script blocks placed within the body of the page to be incorrect. But how would I instrument the button without the onclick attribute you might ask. Consider the following change to the button element button type button id testButton Click Me button Much simpler But now you ll note the button doesn t do anything. Rather than embedding the button s behavior in its markup we ll move it to a script block in the head section of the page outside the scope of the document

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.