Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Updating element styles


As we build our applications and apply a number of styles and properties to define the layout and visual representation of elements, we also need to be able to update and alter the aesthetics and styles to reflect changes or events within the application.

How to do it...

In this recipe, we will read, write, and detect the style properties and class attributes assigned to selected elements using XUI's built-in style functions:

  1. Firstly, create a new PhoneGap project named element by running this line:

    phonegap create element com.myapp.element element
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:

    cordova platform add ios
    cordova platform add android
    
  3. Open www/index.html. Let's clean up the unnecessary elements. Include a reference to the XUI JavaScript library and the Cordova JavaScript file.

  4. We write a new script tag block before the closing head tag, which will hold our custom PhoneGap application code. Define an empty onLoad function inside the...