Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery calc height based on width

$(function() {
  var myDivWidth = $(".main-div").css("width") + "px";
  // the variable will now have our div width
  $(".main-div").css("height", myDivWidth)
  // Another Way
  $(".main-div").css({
    "height": myDivWidth
  })
})
 
PREVIOUS NEXT
Tagged: #jquery #calc #height #based #width
ADD COMMENT
Topic
Name
2+5 =