tailieunhanh - Lập trình .net 4.0 và visual studio 2010 part 43

Một vấn đề thường gặp phải nhiều nhà thiết kế và phát triển là sự tách biệt của thiết kế từ mã. Nhiều nhà phát triển (trên thực tế, tôi đã có em để làm điều này trong ví dụ đầu tiên) nếu được yêu cầu để gọi một chức năng JavaScript khi nhấp vào một nút là sẽ viết một cái gì đó như thế này: | CHAPTER 12 JQUERY Adding Functions A common problem many designers and developers encounter is the separation of design from code. Many developers in fact I got you to do this in the very first example if asked to call a JavaScript function when a button is clicked will write something such as this input id cmdTest type button value Hello jQuery onclick javascript hellojQuery However this is not the best way because it is very vulnerable to polo neck snowboarding designer corruption and isn t standards compliant. jQuery offers a neat solution with the .bind method. The following code binds the hellojQuery function to the click of the cmdTest button cmdTest .bind click hellojQuery Animation Effects Many people become aware of jQuery through seeing one of its many impressive graphical effects. Let s check out the fadeOut effect using our original example. 1. Go back to and change the helloJQuery function to contain the following div1 .fadeOut 2. Press F5 to run your application 3. Click the Hello jQuery button 4. The div should then fade out of view. Effect Overloads Most of the effects in jQuery are overloaded allowing fine-grained control see Table 12-6 . Table 12-6. Different overloads of fadeOut method Example Meaning div1 .fade0ut Basic effect with default options div1 .fade0ut 10000 Effect time specified in milliseconds div1 .fade0ut slow Specifies the time the effect will take to run slow normal or fast 280 CHAPTER 12 JQUERY You can also specify a callback function to be executed when the effect has completed function hellojOuery div1 .fadeOut slow funtionToCall Function functionToCall Core Library Effects Table 12-7 lists jQueries core effects. Table 12-7. Core libary effects Example Meaning div1 .hide Hides element. div1 .show Shows element. div1 .fadeOut Fades out element. div1 .fadeIn Fades in element. div1 .toggle Toggles display of element. If it is hidden it will become visible. If it is visible it will be hidden. div1 .slideDown Animates .

crossorigin="anonymous">
Đã 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.