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

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.