dynamically changing div width - weird problem
I have a div tag and I dynamically set the width of the div... to start with it the width will be 10% and then it will increase based on the value the user enters. This is how I am setting the value dynamically from the javascript. It works fine in FF and Chrome. It works in a weird way in 开发者_如何学GoIE... if I put an alert box after setting the width in the JS it works but if I remove the alert box the div width doesn't change and it stays at the old value.
Can somebody give me some insight on this?
This is the sample code and newval can be anything between range 0 to 100
document.getElementById('test'+id).style.width = newval + '%'
Thanks in advance
Try add the ;
symbol at the end of expression, and concat the result value with "":
document.getElementById('test' + id).style.width = "" + newval + '%';
精彩评论