[英]change jquery masonry css with javascript
I'm trying to dynamically change the css properties of a jquery masonry plugin box. 我正在尝试动态更改jquery石工插件框的css属性。
Essentially, I'm going to make the box expand, i've this code, but it yields no results. 本质上,我将使该框扩展,我有这段代码,但是没有任何结果。
$container.click(function(){
var elem = document.getElementById($container);
elem.style.width="500px";
});
I expect for the width of the block to change to 500px when I click on it, but it doesn't. 我希望单击该块时,该块的宽度会更改为500px,但事实并非如此。
Any insight on dynamically changing css via javascript would be great. 通过javascript动态更改css的任何见解都会很棒。 Thanks!
谢谢!
All you need is: 所有你需要的是:
$(this).css('width', '500px');
in the "click" handler. 在“点击”处理程序中。 (That's assuming that the "container" is the box whose size you want to change.)
(假设“容器”是您要更改其大小的框。)
将处理程序内部更改为
$container.css({width:"500px"});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.