Beginning jQuery by Jack Franklin
Author:Jack Franklin [Franklin, Jack]
Language: eng
Format: epub, pdf
Tags: Computers, Programming Languages, JavaScript, Web, Web Programming
ISBN: 9781430249320
Publisher: Apress
Published: 2013-01-30T05:00:00+00:00
accordion.on("showParagraph", "p", function() {
paragraphs.slideUp("normal");
$(this).slideDown("normal");
});
});
This might not seem easier. In fact, your code is a bit easier, but it’s also more efficient, thanks to delegation, and it is easy to add other ways to trigger the correct paragraph sliding down. If I wanted to trigger a paragraph sliding down from another method, all I have to do is trigger the event on it. It’s simple and extensible.
Summary
You should be pretty comfortable handling events in jQuery. This is good because they are used constantly in any jQuery project, both in this book and in real life. Your accordion is now much nicer and you are able to prevent default behavior, you have a good understanding of event propagation, and you can even trigger your own events. The accordion is now better for it.
It’s still not perfect, however. In Chapter 7, we will dive further into animation, which will highlight some problems with the accordion as it stands. We’ll also explore the more complex areas of animation and, at the end of the chapter, revisit the accordion to improve it.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12587)
Hello! Python by Anthony Briggs(9925)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9800)
The Mikado Method by Ola Ellnestam Daniel Brolund(9785)
Dependency Injection in .NET by Mark Seemann(9347)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7770)
Grails in Action by Glen Smith Peter Ledbrook(7704)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7566)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7143)
Microservices with Go by Alexander Shuiskov(6905)
Practical Design Patterns for Java Developers by Miroslav Wengner(6823)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6765)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Angular Projects - Third Edition by Aristeidis Bampakos(6181)
The Art of Crafting User Stories by The Art of Crafting User Stories(5703)
NetSuite for Consultants - Second Edition by Peter Ries(5634)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5445)
Kotlin in Action by Dmitry Jemerov(5073)
