O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Transforming HTML elements using their IDs

Suppose you are building a page and you want to show some unique information, such as the user name and the total amount of a shopping cart; what would you do?

You will probably need to add the information that you want to show into some tags with a unique identifier.

This is exactly what we will learn to do in this recipe.

Getting ready

You can use the code from the examples we used in the recipes of the previous chapter or you can start a new project.

How to do it...

An HTML element can be transformed by using the following steps:

  1. Add the following code into the index.html file:
    <div data-lift="Calculator.plus">
      2 + 2 = <span id="result">some number</span>
    </div>
  2. Create a Calculator object inside the snippet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required