Hi, I'm trying to add a number to the width of an element but the width value doesn't seem to be numeric even after i remove the "px" from it.
How can i add to an existing width? Below is my stab at it but i get 200200px instead of 400px.
Thanks!
How can i add to an existing width? Below is my stab at it but i get 200200px instead of 400px.
Thanks!
Code:
<?php
echo'<div id="element" style="width:200px;">';
$w = 200;
echo'<script type="text/javascript">
var w = document.getElementById("element").style.width;
w = w.replace(/px/, "");
w = w + '.$w.'+ "px";
document.getElementById("element").style.width = w;
</script>';
?>
Comment