86140

jquery height returning px not vh

Question:

Soo, Im working on an html-editor and setting vh values to div's. But when I try to use $(id).height(); or $(id).css("height"); it is always returning px value and not the vh. This should not be a problem, but I was planing on making is to a user could choose if he wished to use px or vh. So is it another way to get jquery(or js) to tell me what type of height value that is set? My question is not about converting data from px to %, but if it is possible to figure out what type of messurement the height is set as in css. In this case if it was defined as px or vh

Answer1:

You will always get height or width in pixels. You will have to manually convert it to vh or vw value

Here is previous question: <a href="https://stackoverflow.com/a/28295133/1548301" rel="nofollow">https://stackoverflow.com/a/28295133/1548301</a>

<blockquote>

1px = (100 / document.documentElement.clientWidth)vw<br /> e.g. — If your viewport was 500px wide (equals by definition to 100vw) then

1px = (100 / 500) = 0.2vw

</blockquote>

Recommend

  • Is it possible to hide Map but show only markers Android Google Maps
  • Python: accessing attributes and methods of one class in another
  • Refresh Events In Angular Calendar UI (Fullcalendar) With Laravel As A Backend
  • Which Xcode version supports Mac 10.10.5?
  • How do I Dispose a HttpResponseMessage in my Web Api Method?
  • SyntaxError: (irb):26: both block arg and actual block given
  • uml Composition relationships to RDF and OWL
  • Azure table store snapshot/backup capability
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • xtable package: Skipping some rows in the output
  • How can the INSERT … ON CONFLICT (id) DO UPDATE… syntax be used with a sequence ID?
  • WPF - CanExecute dosn't fire when raising Commands from a UserControl
  • Custom validator control occupying space even though display set to dynamic
  • Change multiple background-images with jQuery
  • Scrapy recursive link crawler
  • How to rebase a series of branches?
  • Change JButton Shape while respecting Look And Feel
  • req.body is undefined - nodejs
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Modifying destination and filename of gulp-svg-sprite
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • Change an a tag attribute in JavaScript based on screen width
  • Importing jscolor library in angular 2
  • ORA-29908: missing primary invocation for ancillary operator
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • C# - Getting references of reference
  • How to set the response of a form post action to a iframe source?
  • How do I configure my settings file to work with unit tests?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory
  • Binding checkboxes to object values in AngularJs
  • Converting MP3 duration time
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF