我希望仅在IE浏览器中使用javascript更改元素的宽度,但不知道如何执行此操作。
请尽快帮助我。
答案 0 :(得分:1)
<!--[if IE]>
<script type="text/javascript">
document.getElementById('elementsId').style.width = '250px';
</script>
<![endif]-->
答案 1 :(得分:0)
使用条件评论,或使用javascript检测浏览器。然后使用document.getElementById('id')
检索元素,并更改其宽度。
例如:
document.onload = function()
{
if(navigator.appName == 'Microsoft Internet Explorer')
{
document.getElementById('someElement').style.width = '200px';
}
}
<div id='someElement' style='width:10px'>Some element</div>