Skip to content Skip to sidebar Skip to footer

Jquery - Minus Percentage From Css Pixel Value

I'm trying to get a bunch of background-position-y values from a number of elements and minus a percentage from the pixel value and then assign that new value to each element. E.g.

Solution 1:

Try the shortz:

jq(this).css('background-position-x','-=30%');

or as Klaus said:

jq(this).css('background-position-x','*=.7');

If you go DRY try this:

jQuery(this).css({backgroundPositionX:'*=.7', backgroundPositionY:'*=.7'});

Solution 2:

var bgPosYNew = bgPosY - (bgPosY * 0.3); this should work

Post a Comment for "Jquery - Minus Percentage From Css Pixel Value"