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.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.