I've got a jQuery function to modify the width values of two CSS classes. The width is given in percentage for both classes. As written, it works, but I'm trying to optimize my jQuery code so it works with just variables. Here is the relevant code (percent is an earlier defined variable):
$('.eventdescription').css({width : 75 - percent + '%'});
$('.function').css({width : 25 + percent + '%'});
I'm trying to get rid of the '75' and '25' values. I've tried the following:
$('.eventdescription').css({width : -=percent + '%'});
$('.function').css({width : +=percent + '%'});
But I get an 'unexpected identifier' error. Enclosing '+=percent' and '-=percent' in quotes doesn't seem to do anything. What am I doing wrong? Thanks for reading.
EDIT: See Tom Chung's answer. The correct syntax is enclosing the += and -= operators in quotes and including them as discrete units in the operation.