Chapter 12
One approach is to set the style of the element inline using the
styleattribute. You can also usegetComputedStyleorcurrentStyle, 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.You can set font size and line height at the same time:
obj.style.font="14pt/16pt"; obj.style.color="#f00";
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.
One way is to resize it out of existence by setting either the
widthorheightto zero. You can also clip the element to the top, bottom, left, or, right. You can also hide it by settingvisibilitytohidden, or turn off the display. Finally, you can make it move off the page, or move another element in front of it.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