TAILIEUCHUNG - apress pro php and jquery 2010 phần 3

và những gì họ làm sẽ chứng minh vô giá khi bạn bắt đầu xây dựng dự án ví dụ sau này trong cuốn sách trong những tính năng thuận tiện nhất của jQuery là một thực tế rằng gần như tất cả các phương pháp của nó là chainable, có nghĩa là phương pháp có thể được thực hiện ngay sau khi khác. | CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS Figure 2-20. Using .each the expected results are produced Using Animation and Other Effects One of the most exciting features of jQuery is its library of methods that allow for animation and special effects which are all possible with plain JavaScript but are incredibly easy using jQuery. A traditional JavaScript approach is tricky and much more involved. Note Because it s difficult to show animations as static images you ll need to rely on your browser for an illustration of how these examples should look. For live demonstrations of the different animation effects visit the jQuery API at http and look up the individual method you wish to see demonstrated. .show and .hide The most basic effects functions are .show and .hide . When fired without a parameter they simply add or remove display none from the element s style attribute. Hide the paragraph with ID bar using the following bar .hide 65 CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS The paragraph disappears from the browser window but is still visible in the DOM using the element inspector. To bring it back into view call .show bar .show The element comes back as it was before. To make the hiding and showing of elements animated the duration in milliseconds can be passed as well as an optional callback to be fired after the animation is complete. To demonstrate add a background and border to the paragraph with ID bar and then hide it with a duration of 2 seconds and a callback function that will log a message in the console bar cSs background yellow border 1px Solid black . . . . . .hide 2000 function Animation complete Upon execution the CSS styles are added to the element and the .hide method fires. This causes the element to shrink horizontally and vertically as well as fading its opacity. After two seconds it will finish disappearing and the callback function logs the Animation complete message in the console. Note The callback function

Đã 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.