jQuery: Set the width of an element in percent
Question by Guest | 2018-12-14 at 23:19
I would like to change the width of some elements with jQuery. The information should be provided in percent, so I would like to set the element with the id "div1" to 50% width, for example. Is that possible?
Related Topics
jQuery: Does an Element exist?
Tip | 1 Comment
Lazarus/Delphi: Width and ClientWidth - Difference
Info | 0 Comments
jQuery: Show and hide elements
Tutorial | 0 Comments
JavaScript and jQuery: Replace content of an element by using innerHTML
Tutorial | 0 Comments
jQuery: CSS Stylesheet Switcher
Tutorial | 1 Comment
jQuery: Count Elements, Images, Classes etc
Tip | 0 Comments
HTML: Difference between ID and CLASS
Info | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
You can use the function width() for that.
With the code
you are setting the width of
to 50 %.
2018-12-15 at 19:56
You can also directly address the CSS of your element. That would look like this:
The result would of course be the same.
2018-12-15 at 21:47