Sorry, I thought you meant the
position property (absolute, etc.).
The value from an input is always text (a string) initially, so you need to convert it to a number; multiplying by 1 is one way to do this:
Code:
if(property == 'top') {
$('#testDiv').css("top",(value * 1));
}
else if(property == 'left') {
$('#testDiv').css("left",(value * 1));
}
You might want to add pixels as well, to ensure it will work in all browsers, although, these days, it probably will anyway:
Code:
if(property == 'top') {
$('#testDiv').css("top",(value * 1) + 'px');
}
else if(property == 'left') {
$('#testDiv').css("left",(value * 1) + 'px');
}
The height() and width() jQuery methods will automatically convert to a number, which is why these were working.