window.onload = function () {
document.getElementById('btn').onclick = function () {
//document.getElementById('dv').style.styleFloat = 'right';
if (typeof ((document.getElementById('dv').style.styleFloat) == 'string')) {
document.getElementById('dv').style.styleFloat = 'right';
} else {
document.getElementById('dv').style.cssFloat = 'right';
};
};
};
<input type="button" name="name" value="层浮动" id="btn" />
<div id="dv" style=" width:300px; height:200px; background-color:Green;">
</div>
document.getElementById('btn').onclick = function () {
//document.getElementById('dv').style.styleFloat = 'right';
if (typeof ((document.getElementById('dv').style.styleFloat) == 'string')) {
document.getElementById('dv').style.styleFloat = 'right';
} else {
document.getElementById('dv').style.cssFloat = 'right';
};
};
};
<input type="button" name="name" value="层浮动" id="btn" />
<div id="dv" style=" width:300px; height:200px; background-color:Green;">
</div>