javascript - How to get width in percentage using jquery -


i trying value of width in percentage using j-query. don't want set value of in j-query.i had tried width() method , css('width').they both return not return result in percentage.

html-code

style.css

.demo{ width:50%; } 

jquery code

$(document).ready(function(){ var = $('.demo').css('width');//50px var = $('.demo').width();//50 }); 

thanks in advance help.

$(function() {   var parentwidth = $(document).width(); // parent element   var demowidth = ($(".demo").width()/parentwidth * 100).tofixed() +"%"; }); 

this give width in %


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -