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

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -