TAILIEUCHUNG - Phát triển Javascript - part 23

Tham khảo tài liệu 'phát triển javascript - part 23', 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ả | Unobtrusive Tabbed Panel Example 193 Listing Using the tab controller function if typeof document undefined return var dom var ol news-tabs . try var controller ol js-tabs function curr prev getPanel prev active-panel getPanel curr active-panel a 0 catch e The getPanel function used in the above example uses the semantic markup to find which panel an anchor should toggle. It extracts the part of the anchor s href attribute after the hash character looks up elements with corresponding names and finally picks the first one it finds. It then traverses the element s parent until it finds a div element. The method can be seen in Listing . Listing Finding the panel to toggle function . function getPanel element if element typeof string return null var target . var panel target 0 Download from 194 Unobtrusive JavaScript while panel div panel return panel . Note that getPanel defensively checks its argument and aborts if it doesn t receive an actual element. This means that we can fearlessly call it using the curr and prev anchors in the onTabChange method even though the prev argument will be undefined the first time it is called. To make the tabbed panels appear as panels we can sprinkle on some very simple CSS as seen in Listing . Listing Simple tabbed panel CSS .js-tabs .section clear left display none .js-tabs .active-panel display block .js-tabs .nav border-bottom 1px solid bbb margin 0 0 6px overflow visible padding 0 .js-tabs .nav li display inline list-style none .js-tabs .nav a background eee border 1px solid bbb line-height Download from Unobtrusive Tabbed Panel Example .

TỪ KHÓA LIÊN QUAN
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.