I don't think I'm correctly understanding jQuery chaining. I'm looping through an array and trying to add div elements to my wrapper CSS class with each div element having a class of 'click' and custom css top and left attributes, like this:
$('<div></div>').appendTo('.wrapper').addClass('click').css('top',click.y).css('left'.click.x);
But it fails to work as expected - it adds one div element, sets my .wrapper div's class to 'click' and then stops.
If I remove
.css('top',click.y).css('left'.click.x);
it works as expected - adding new div elements to the wrapper div.
How can i get this to work properly? Thanks
Use a JSON object for .css
.
.css({
'left' : click.x,
'top' : click.y
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With