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

Resizing Elements

$("#up").on("click", function(){   $("#photo").width($("#photo").width()*1.2); }); $("#down").on("click", function(){   $("#photo").width($("#photo").width()*.8); });

Another important aspect when dynamically working with HTML elements is the ability to get and change an element’s size. jQuery makes this simple using a set of methods attached to the jQuery object. Table 8.1 shows the methods provided by jQuery objects that allow you to get the height and width of an element.

Image

Table 8.1 jQuery Object Methods to Get and Set the Element Size

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