Adola
Adola

Reputation: 588

change jquery masonry css with javascript

I'm trying to dynamically change the css properties of a jquery masonry plugin box.

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.

Any insight on dynamically changing css via javascript would be great. Thanks!

Upvotes: 0

Views: 150

Answers (2)

Carl
Carl

Reputation: 7554

Change the handler internals to

   $container.css({width:"500px"});

Upvotes: 1

Pointy
Pointy

Reputation: 413846

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.)

Upvotes: 2

Related Questions