Width & Height
With SniperJs, it is easy to work with the dimensions of elements and browser window.
SniperJs width() and height() Methods
$("#container").width();$("#container").height();$("button").click(()=>{
let boxWidth = $("#div1").width(); // gets the width of the selected element
let boxHeight = $("#div1").height(); //get height of the selected element
});$("#container").width('200px'); // set 200px
$("#container").width('100%'); // sets 100%
$("#container").width(100); // sets 100px$("#container").height(500); //sets 500px$("button").click(function(e){
let boxWidth = $("#div1").width(120); // sets 120px width to the selected element
let boxHeight = $("#div1").height(500); //sets 500px height to the selected element
});Functional Setting of Width and Height
Last updated