setting width of div jquery

落花浮王杯 提交于 2019-12-11 09:14:21

问题


I'm trying to set the width of a div using jquery.

this is how I'm trying to set the size of the div

$('#page').css("width",data[0]['imageWidth']);

and this is the div I'm trying to set

<div id="page">
 </div>

any help with this would be much appreciated


回答1:


In CSS lengths require a unit, in this case most likely Pixel (px):

$('#page').css("width",data[0]['imageWidth'] + "px");


来源:https://stackoverflow.com/questions/3881693/setting-width-of-div-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!