TAILIEUCHUNG - JQuery: Novice to Ninja- P8

JQuery: Novice to Ninja- P8:No matter what kind of ninja you are—a cooking ninja, a corporate lawyer ninja, or an actual ninja ninja—virtuosity lies in first mastering the basic tools of the trade. Once conquered, it’s then up to the full-fledged ninja to apply that knowledge in creative and inventive ways. | 82 jQuery Novice to Ninja chapter_03 18_layout_switcher excerpt document .ready function stylesheetToggle window .resize stylesheetToggle function stylesheetToggle if body .width 900 link rel stylesheet href type text css .appendTo head else link href .remove We ve named our function stylesheetToggle and called it twice once when the document first loads and again whenever we resize. You ll notice that we only need to pass the function s name to the resize event handler since we are not declaring a function here we have no need for the the function keyword or any curly braces or parentheses. Resizable Elements The jQuery UI library contains a Resizable plugin as part of its interaction functionality. The Resizable plugin makes elements that you select able to be resized by adding a small handle to the bottom corner of the element. This can be stretched around with the mouse much like your operating system s windows . Like all jQuery UI components it s highly configurable and easy to use. If you downloaded the full jQuery UI library earlier you ll already have the class ready to go. Otherwise you ll need to head back to the download builder and include the Resizable com-ponent which will also require the core library and a theme. Using the Resizable component in its most basic form is very easy. We simply select the element or elements we want to modify and call the resizable function chapter_03 19_resizable_elements excerpt p .resizable Animating Scrolling and Resizing 83 If we run this on our StarTrackr site we re in for some unusual results every paragraph element instantly becomes resizable It s a lot of fun to see this in action suddenly our whole web page becomes malleable. By default the Resizable interaction adds small handles in the bottom-right corners of the elements. These are styled in the jQuery UI style sheet so have a look in there if you re interested in changing the way they look. The default handles are .

TÀI LIỆU LIÊN QUAN