Ben G
Ben G

Reputation: 253

Modify CSS in jQuery

I am a noob of jQuery, and I have tried the following code but doesn't work. Can anyone tell me how to assign leftValue to "left" as following code using jQuery?

var i =0;
var leftValue = seat_xcoord*20;
$('#seat'+i).css({left: $leftValue});

Cheers.

Upvotes: 2

Views: 79

Answers (2)

Sushanth --
Sushanth --

Reputation: 55750

Try this

$('#seat'+i).css({left: leftValue + 'px'});

You had $leftValue instead of leftValue

And make sure there is element with id="seat0"

Check DEMO

Upvotes: 8

jimp
jimp

Reputation: 17487

Remove the $ from your leftValue variable and concatenate "px" for pixel units.

Upvotes: 0

Related Questions