Skip to Content
Learning JavaScript
book

Learning JavaScript

by Shelley Powers
October 2006
Beginner to intermediate
352 pages
9h 33m
English
O'Reilly Media, Inc.
Content preview from Learning JavaScript

Chapter 12

  1. One approach is to set the style of the element inline using the style attribute. You can also use getComputedStyle or currentStyle, taking care to compensate for browser differences. A third approach is to store the current settings in a global variable and access it, rather than the actual setting.

  2. You can set font size and line height at the same time:

  3. obj.style.font="14pt/16pt";
    obj.style.color="#f00";
  4. If the text is in an element contained within the one whose style you’ve altered, and this inner element has a different style setting, it will override your setting.

  5. One way is to resize it out of existence by setting either the width or height to zero. You can also clip the element to the top, bottom, left, or, right. You can also hide it by setting visibility to hidden, or turn off the display. Finally, you can make it move off the page, or move another element in front of it.

  6. Try a mouse-click event handler attached to the image of an item, in combination with a “Buy me” hypertext link for keyboard events; this could move the item to a shopping cart using animation or instantaneously. This effect cuts the amount of coding, ensures the effect is accessible, and is still pretty cool.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning JavaScript, 2nd Edition

Learning JavaScript, 2nd Edition

Shelley Powers

Publisher Resources

ISBN: 0596527462Catalog PageErrata