0

是否可以使用jQuery更改下面的宽度值

 <div style="width:75%" id="twitter" class="bar"></div>
 <div style="width:75%" id="other2" class="bar"></div>
 <div style="width:75%" id="something" class="bar"></div>

我努力了

jQuery(document).ready(function($) {
   $('#twitter').css({
   "width":"5%",
   });
)};

这是我的jsfiddle

http://jsfiddle.net/LSwwB/1/

谢谢

4

3 回答 3

3

您的代码中有几个错误。已在http://jsfiddle.net/LSwwB/3/上修复。

第 3 行:最后一个属性后没有逗号。
第 5 行:)};应该是});

于 2013-01-21T17:16:13.923 回答
0

那应该可以正常工作(使用其他人发布的语法修复)。稍微简单的是 jQuery 的 Width 函数:http ://api.jquery.com/width/#width2

$('#twitter').width('5%');
于 2013-01-21T17:15:32.500 回答
0
   jQuery(function($) {
        $('#twitter').css({width:"5%"}); // <-- extra ','
   });  // <-- instead of mustache add a beard to that fella
于 2013-01-21T17:17:01.630 回答