+ 2

Width method in jQuery

Normally width method returns in pixels but some time we added width using CSS like #demo{ width:20% } if we are getting width using jQuery alert($('#demo'). width ()); sometimes it return in present. it's not happen every time but sometimes happens. I faced this issue in my last project so be careful. it maybe helpful for you. Thanks

29th Dec 2016, 3:15 PM
Avanish Kumar
Avanish Kumar - avatar
2 ответов
+ 4
do: style.width
3rd Jan 2017, 1:24 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 1
sooo...you want to say If we use width value in % it will not be always returned using JQ in % o.O? at least with .width ? how about $(#demo).css('width')? guess it's better to use css if we wanna get or change css property. width and height mostly about browser sizes,for example...at least I feel so... But anyway...ty for info,maybe you just solved my future mistake:)
2nd Apr 2017, 10:46 PM
Rose Sevenyears
Rose  Sevenyears - avatar