O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

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

Adjusting Opacity

$("#up").on("click", function(){   var op = parseFloat($("#photo").css("opacity"));   if (op<1) {op += 0.2;};   $("#photo").css("opacity", op); }); $("#down").on("click", function(){   var op = $("#photo").css("opacity");   if (op>0) {op -= 0.2;};   $("#photo").css("opacity", op); });

Changing the opacity of elements is a great way to alter the layout of the page. Lowering the opacity value makes the item less visible, revealing any elements or background images that are behind the item.

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