开发者

Jquery change width of div

I want to change the width of elements rendered using following code. I have tried adding style width:xxpx element in definition and try defining a new css class to invail. I want both the containers under main container to be of same size. But the following code is rendering approximately 40-60. I am using the style sheets from jquery ui(jquery-ui-1.7.1.custom.css).

 this.container = $('<div class="ui-multiselect ui-helper-clearfix ui-widget" ></开发者_如何学编程div>').insertAfter(this.element);
 this.availableContainer = $('<div class="ui-widget-content list-container available"></div>').appendTo(this.container);
 this.selectedContainer = $('<div class="ui-widget-content list-container selected"></div>').appendTo(this.container);

Help?


var newWidth = this.container.width() / 2;    //I assume you want the child divs to be half the size of the parent?
this.availableContainer.width(newWidth);
this.selectedContainer.width(newWidth);

This is how to do what you asked, change the width of the DIVs with jQuery.

You should probably keep bashing away at the CSS and try and get the styles set with your stylesheet if your website/app is expected to function without JavaScript.

Link to working example: http://jsfiddle.net/Phu6y/5/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜