I'm trying to make a script which in realtime changes a DIV to float either left or right but somehow I'm doing something wrong? Here is what I got... function logoplace(that){ document.getElementById('logoholder').style.float=that } Code (markup): <style type="text/css"> div#logoholder { float:left; border:1px solid #666666; } </style> <input type="radio" name="logoplacement" value="left" onclick="logoplace(this)" /> Left <input type="radio" name="logoplacement" value="right" onclick="logoplace(this)" /> Right <br><br> <div id="logoholder">This is a test</div> HTML: What am I doing Wrong?
No, style.float is correct. You're just not passing the setting to your function. Try: <input type="radio" name="logoplacement" value="left" onclick="logoplace('left')" /> Left <input type="radio" name="logoplacement" value="right" onclick="logoplace('right')" /> Right Code (markup): Using the explicit setting in the call to logoplace() eliminates the need to check the control's value or current setting, which may not be correct when the onclick() function is executed.
@rainborick man style.float is (unfortunately) incorrect - u dont belive me? try it! btw below is working (tested!) code: cssFloat - works for firefox and chrome styleFloat - works for IE dont know about other browsers because i dont use them
Sorry about that. You're right about the property name. But his code still needed the changes I suggested as well.