
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to set height equal to the dynamic width (CSS fluid layout) in JavaScript?
To set height equal to the dynamic width in JavaScript, you can try to run the following code −
Example
<!DOCTYPE html> <html> <head> <style> .wrap { width:400px; height:300px; border:2px solid yellow; } .myChild{ width: 80%; border:1px solid red; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script> var res = $('.myChild').width(); $('.myChild').css({ 'height': res + 'px' }); </script> </head> <body> <div class = "wrap"> <div class = "myChild"></div> </div> </body> </html>
- Related Articles
- How to set viewport height and width in CSS
- How to set the table layout algorithm using CSS ?
- How to set cell width and height in HTML?
- How to set the height/width of a Label widget in Tkinter?
- How to create equal height columns with CSS?
- Define the width of each column in CSS Grid Layout
- The width and height properties in CSS
- Set the height and width of an image using percent with CSS
- How to get the Width and Height of the screen in JavaScript?
- How I can set the width and height of a JavaScript alert box?
- How to set the width of an element in JavaScript?
- How to set dynamic property keys to an object in JavaScript?
- Set areas within the grid layout in CSS
- How to set width and height of an element using jQuery?
- Width and Height of Elements in CSS

Advertisements