I am trying to calculate half of the width of an object using Javascript.
var img = document.getElementById('picture1');
var width = img.clientWidth;
var halfwidth = width/2;
I then need to plug that variable into a jquery css modifier for margin-left. This will be used to position the image in the exact center of the page.
$('#div').css('margin-left','-400px');
but instead of -400px, I need to have the variable in there somehow. Can this be accomplished?
I think this will work for you: