Hi,
I'm facing a problem with this one. I made a js script which checks the height of an element and increases it with 30px. Everything is working fine but then comes the problem with summing the height and 30 px.
This is my code:
html:
The alert is to show the result. Die to the fact it's not summing I didn't made the code which changes the height of the element but that's a easy one ;)
Any help will be appreciated !
Thanks in advance,
Steve
I'm facing a problem with this one. I made a js script which checks the height of an element and increases it with 30px. Everything is working fine but then comes the problem with summing the height and 30 px.
This is my code:
Code:
function add(elmnt)
{
if(elmnt != null || elmnt != 'undefined')
{
var height = document.getElementById(elmnt).style.height;
var check = /px/gi;
var clearHeightPx = height.replace(check, '');
var clearHeight = clearHeightPx.replace(/^\s+|\s+$/g, "");
var newHeight = eval(clearHeight+30);
alert(newHeight);
}
}
Code:
<div id="div1" style="height: 200px;">
<img src="justanimage" alt="justanimage" onclick="add('div1')">
</div>
Any help will be appreciated !
Thanks in advance,
Steve
Comment