Throughout the first four chapters of this book, we have been using the .addClass() and .removeClass()Â methods to demonstrate how we can change the appearance of elements on a page. Although we discussed these methods informally in terms of manipulating the class attribute, jQuery actually modifies a DOM property called className. The .addClass()Â method creates or adds to the property, while .removeClass() deletes or shortens it. Add to these the .toggleClass() method, which alternates between adding and removing class names, and we have an efficient and robust way of handling classes. These methods are particularly helpful in that they avoid adding a class if it already exists on an element (so we don't end up with <div class="first first">, for example), and correctly handle cases where multiple classes are applied to a single element, such...
United States
United Kingdom
India
Germany
France
Canada
Russia
Spain
Brazil
Australia
Argentina
Austria
Belgium
Bulgaria
Chile
Colombia
Cyprus
Czechia
Denmark
Ecuador
Egypt
Estonia
Finland
Greece
Hungary
Indonesia
Ireland
Italy
Japan
Latvia
Lithuania
Luxembourg
Malaysia
Malta
Mexico
Netherlands
New Zealand
Norway
Philippines
Poland
Portugal
Romania
Singapore
Slovakia
Slovenia
South Africa
South Korea
Sweden
Switzerland
Taiwan
Thailand
Turkey
Ukraine