About the Authors Jonathan Chaffer is a member of Rapid Development Group, a web development firm located in Grand Rapids, Michigan. His work there includes overseeing and implementing projects in a wide variety of technologies, with an emphasis in PHP, MySQL, and JavaScript. He also leads on-site training seminars on the jQuery framework for web developers. In the open-source community, Jonathan has been very active in the Drupal CMS project, which has adopted jQuery as its JavaScript framework of choice. He is the creator of the Content Construction Kit, a popular module for managing structured content on Drupal sites. He is responsible for major overhauls of Drupal’s menu system and developer API reference. Jonathan lives in Grand Rapids with his wife, Jennifer. I would like to thank Jenny for her tireless enthusiasm and support, Karl for the motivation to continue writing when the spirit is weak, and the Ars Technica community for constant inspiration toward technical excellence. In addition, I’d like to thank Mike Henry and the Twisted Pixel team for producing consistently entertaining distractions in between writing sessions.

How we run the project, and how you use the code, is fundamentally very different from most open source projects and most JavaScript libraries. The jQuery project and community is incredibly knowledgeable; we understand what makes jQuery a different programming experience and do our best to pass that knowledge on to fellow users. The jQuery community isn’t something that you can read about to understand; it’s something that you actually have to participate in for it to fully sink in. I hope that you’ll have the opportunity to partake in it. Come join us in our forums, mailing lists, and blogs and let us help guide you through the experience of getting to know jQuery better. For me, jQuery is much more than a block of code. It’s the sum total of experiences that have transpired over the years in order to make the library happen. The considerable ups and downs, the struggle of development together with the excitement of seeing it grow and succeed. Growing close with its users and fellow team members, understanding them and trying to grow and adapt. When I first saw this book talk about jQuery and discuss it like a unified tool, as opposed to the experiences that it’s come to encapsulate for me, I was both taken aback and excited. Seeing how others learn, understand, and mold jQuery to fit them is much of what makes the project so exhilarating. I’m not the only one who enjoys jQuery on a level that is far different from a normal tool-user relationship. I don’t know if I can properly encapsulate why this is, but I’ve seen it time and time again the singular moment when a user’s face lights up with the realization of just how much jQuery will help them. There is a specific moment where it just clicks for a jQuery user, when they realize that this tool that they were using was in fact much, much more than just a simple tool all along and suddenly their understanding of how to write dynamic web applications completely shifts. It’s an incredible thing, and absolutely my favorite part of the jQuery project. I hope you’ll have the opportunity to experience this sensation as well. John Resig Creator of jQuery

Foreword I feel honored knowing that Karl Swedberg and Jonathan Chaffer undertook the task of writing Learning jQuery. As the first book about jQuery, it set the standard that other jQuery and, really, other JavaScript books in general have tried to match. It’s consistently been one of the top selling JavaScript books since its release, in no small part due to its quality and attention to detail. I’m especially pleased that it was Karl and Jonathan who wrote the book as I already knew them so well and knew that they would be perfect for the job. Being part of the core jQuery team, I’ve had the opportunity to come to know Karl quite well over the past couple years, and especially within the context of his book writing effort. Looking at the end result, it’s clear that his skills as both a developer and a former English teacher were perfectly designed for this singular task. I’ve also had the opportunity to meet both of them in person, a rare occurrence in the world of distributed Open Source projects, and they continue to be upstanding members of the jQuery community. The jQuery library is used by so many different people in the jQuery community. The community is full of designers, developers, people who have experience programming, and those who don’t. Even within the jQuery team, we have people from all backgrounds providing their feedback on the direction of the project. There is one thing that is common across all of jQuery’s users, though: We are a community of developers and designers who want JavaScript development to be made simple. It’s almost a clich , at this point, to say that an open source project is community- oriented, or that a project wants to focus on helping new users get started. However, it’s not just an empty gesture for jQuery; it’s the liquid-oxygen fuel for the project. We actually have more people in the jQuery team dedicated to managing the jQuery community, writing documentation, or writing plugins than actually maintaining the core code base. While the health of the library is incredibly important, the community surrounding that code is the difference between a floundering, mediocre project and one that will match and exceed your every need.

Learning jQuery Third Edition Copyright 2011 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: September 2011 Production Reference: 1160911 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.. ISBN 978-1-84951-654-9 www.packtpub.com Cover Image by Karl Swedberg (kswedberg@gmail.com)

366 Part III: Designing Sites for Long-Term Success Reporting. If you re buying ads, you re going to want regular, comprehensive reports to see how the advertising is working. Similarly, if you are hosting ads, you may want to track which ads seem to be influencing your site visitors behavior. Most companies offering advertising also offer extensive reporting. Cost. Web ads can vary greatly in cost and type. Research to decide which advertising type is best for you. Along with ad hosting services, you can also consider running your own ad server software. note There are a large number of advertising services. The oldest and most well known is DoubleClick (www.doubleclick.com/), whose site offers a lot of helpful information covering a wide range of promotion and marketing for Web sites. For a good article on running your own ad server software, see Evaluating Ad Management Software by Bruce Morris, at www. webdevelopersjournal.com/articles/ad-management.html. Secret #240: Add Sponsored Links Sponsored linking is a phenomenon that staken off like crazy and seems to be one of the few new ideas to hit Web advertising. A sponsored link is a text link that can appear in the form of an ad or a simple link. You pay for the sponsorship, and the link is then extremely well targeted to appear on search engines or Web sites based on relevance. That relevancy seems to be a key component of sponsored link popularity. An excellent example of a sponsored link program is Google AdWords. Do any search on Google and you ll wind up seeing several links on the top and to the right side of the search results page. These are sponsored links, and if you compare the topic of your search to the resulting links, you ll see that the relevancy is pretty exacting. I put in the search term dog breeds and the sponsored links that appeared were both for breeder directories. You can purchase AdWords to run on Google (pricing structure is very sensible and guided by your budget needs), or use Google sAdSense, which allows you to build revenue by running others ads on your site all targeted by relevance (see the example in Figure 14-5). note To learn more about Google AdWords, see https://adwords.google .com/select/. To read more about AdSense, see www.google .com/adsense/. For bloggers or other sites where a wide range of topics might be freely discussed, this approach has been found to be controversial, largely due to Google policy. If you d like to read about the controversy, see www.kottke .org/03/10/google-adsense-sucks. The issues described pertain specifically to personal blogs rather than professional sites, but it s always good to be informed.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

Chapter 14: Improving Site Ranking and Managing 365 Site Type Promotional Possibilities Dating site Romantic getaway contests, seasonal promotions for Valentine s day, grand prizes for successful matches who meet and marry Weather Web site Weather trivia polls, seasonal promotions, such as Sensational Spring or Sizzling Summer promotions with contests and prizes such as weather trivia and vacation getaways The key is to match your promotions to your audience and product or service. This is one part of promotions I really happen to like, because it can be great fun and extremely creative to sit down with friends or team members and come up with great ideas. Even if you re limited in budget, there s usually some way to provide innovative, interactive contests and promotions that engage your clients. Secret #239: Learn More About Web Ads The controversy around Web ads rages on, and there remains very little real evidence as to their success. Sometimes they are effective, sometimes not. The key is to determine for your own site whether buying ads to promote your site or hosting Web-based advertising as a means of enhancing revenue for your site is a reasonable choice. Some issues to consider include the following: Ad placement. This issue refers to both cases of hosting ads, and buying them. If you are hosting, you want to make clear which areas of your site have ads, and how they will be managed. Similarly, research your placement options if you are buying placement elsewhere. Provision. Numerous vendors manage Web ads. Find one with a good track record and good customer support. Ad types. Whether buying or hosting ads, find out what kinds of ads are considered conventional in terms of dimension, weight, location, and file type (animated GIFs, rich media advertising via Flash). Integration into design. If you are going to be placing ads on your site, you ll want to successfully integrate them. Ads can be an eyesore but they need to be placed so that your visitors can see them, or they re not going to be worth much. You must find a balance. Fortunately, there are some helpful conventions you can use, but knowing that you want to support ads going into a design is a lot easier than trying to retrofit a design around advertising. Ads are best managed earlier on in the site design process or during a site redesign (see Chapter 15, Dealing with Growth and Redesign ). How to manage ad code. If you are hosting ads on your site, the ad management software or host that you choose is going to be sending you the ad markup. Usually, this markup is filled with problem code, and as you try to clean up your code, the frustration level can get a little out of hand. Plan to test or research the actual code so you know what you re getting into.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

364 Part III: Designing Sites for Long-Term Success to those readers as a means of rewarding their ongoing loyalty and interest in my work. Figure 14-4 shows a significant spike in site visits after a newsletter campaign. Figure 14-4: A spike in site visits occurred after a newsletter campaign. Secret #238: Run Regular and Seasonal Promotions To create interest in your site and brand or build personal relationships, regular promotions can really help. People like getting a break, or even better, free stuff. Depending upon what you re promoting and to whom, the type of promotions you want to run will vary. Table 14-2 describes several scenarios and suggestions for regular and seasonal promotions. Table 14-2: Regular and Seasonal Promotion Ideas Site Type Promotional Possibilities DJ Web site CD giveaways, trivia contests with prizes, show ticket giveaways, yearly concern promotion event. Heart disease information Web site Health-related book giveaways, monthly promotions for heart health, healthy cooking recipe contests, exercise equipment promotions, discount vouchers for healthy heart testing

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

Chapter 14: Improving Site Ranking and Managing 363 Secret #237: Use Opt-In E-mail Newsletters to Drive Traffic Despite the scourge of spam and viruses that have hit e-mail users in the past years, e-mail remains the killer application. E-mail newsletters are undeniably powerful tools to build audience and encourage real relationships between you and your site visitors and customers. The key to avoiding guerrilla tactics in e-mail advertising is to make all e-mail newsletters optional. You will have people opt in mostly via your Web site, which means they have to get to your Web site in the first place. Once visitors do opt in, you can begin building a personal mailing list, which in turn encourages return visits to your site. tip There are numerous directories to which you can post announcements about new e-mail lists. These directories can be helpful because they provide a means of getting interested readers and promoters together. Some of the important factors to consider when initiating opt-in e-mail newsletters are as follows: What are the specific results you want from the e-mail? (Sales? More eyes on your site?) Do you want to offer HTML e-mail? Many e-mail experts say that HTML e-mail is the only way to go, but HTML e-mail may be problematic or undesirable for certain audiences. What kind of content are you going to offer (such as articles, reviews of products, tips and tricks, interviews, and polls)? How long will your newsletter be? Most e-mail experts say that keeping content short and to the point wins the day. How often will you send the newsletter out to subscribers? note Most e-mail newsletter services offer reasonably priced assistance for managing HTML versus text e-mail, tracking e-mail responses, statistics, demographics, and additional helpful tools that you can use to increase your awareness of how well your e-mail campaign is working. Experts do suggest that you spend time creating a plan to start e-mail newsletters, and also build in a way to assess how effective your plan is working. This way, you can adjust to the needs of your audience as time goes on. tip Generally speaking, you should send your e-mails during the week. Some studies suggest that most people open newsletters between Tuesday and Thursday. While weekends are often considered bad times to send newsletters, it really will depend upon your audience. If you are selling sports products, movies, or other recreational products, the weekend might be the perfect time to grab some attention. I have an opt-in newsletter on my site, and I have several thousand people on that list. One of the things I do regularly is to focus special promotions and giveaways

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services