I just wrote the following script for something I'm working on:
----------------------------------------------------------------------------
-------------------
<html>
<head>
<script type="text/javascript">
function KP_growit(subje ct,widthto,heig htto) {
var target = document.getEle mentById(subjec t);
var tweenit = setInterval(gro wer,10);
function grower() {
(parseInt(targe t.style.width) < widthto)? target.style.wi dth =
(parseInt(targe t.style.width) + 10) + "px";
(parseInt(targe t.style.height) < heightto)? target.style.he ight =
(parseInt(targe t.style.height) + 10) + "px";
(parseInt(targe t.style.width) == widthto && parseInt(target .style.height)
== heightto)? clearInterval(t weenit);
}
}
</script>
</head>
<body>
<div id="bluebox" style="position :absolute; left:173px; top:48px;
width:100px; height:80px; z-index:1; background-color:#99CCFF;" ></div>
<div><a href="#" onClick="KP_gro wit('bluebox',4 00,300); return false;">grow
it</a></div>
</body>
</html>
----------------------------------------------------------------------------
--------------------------------------------
I noticed that the script does not work because of the conditional
operators; however it DOES work when using the if...else format. Why is
this? Can someone please help. Thanks.
----------------------------------------------------------------------------
-------------------
<html>
<head>
<script type="text/javascript">
function KP_growit(subje ct,widthto,heig htto) {
var target = document.getEle mentById(subjec t);
var tweenit = setInterval(gro wer,10);
function grower() {
(parseInt(targe t.style.width) < widthto)? target.style.wi dth =
(parseInt(targe t.style.width) + 10) + "px";
(parseInt(targe t.style.height) < heightto)? target.style.he ight =
(parseInt(targe t.style.height) + 10) + "px";
(parseInt(targe t.style.width) == widthto && parseInt(target .style.height)
== heightto)? clearInterval(t weenit);
}
}
</script>
</head>
<body>
<div id="bluebox" style="position :absolute; left:173px; top:48px;
width:100px; height:80px; z-index:1; background-color:#99CCFF;" ></div>
<div><a href="#" onClick="KP_gro wit('bluebox',4 00,300); return false;">grow
it</a></div>
</body>
</html>
----------------------------------------------------------------------------
--------------------------------------------
I noticed that the script does not work because of the conditional
operators; however it DOES work when using the if...else format. Why is
this? Can someone please help. Thanks.
Comment