如图, 我想通过JS 来获取ID为mapDiv这个标签下的 第三个div 当获取到第三个div的时候 我想把这个div中的 left:1352px; 修改为 right:20px; 该怎么写?
window.onload = function() {
var mapDiv = document.getElementById("mapDiv");
var mapDiv_children = mapDiv.children;
var index = 0;
for(var i = 0; i < mapDiv_children.length; i++) {
if(mapDiv_children[0].tagName.toUpperCase() === 'DIV') {
index++;
if (index === 3) {
mapDiv_children[i].style.left = 'auto';
mapDiv_children[i].style.right = '20px';
break;
}
}
}
};
<script type="text/javascript">
window.onload = function() {
var mapDiv = document.getElementById("mapDiv");
var mapDiv_divs = mapDiv.getElementsByTagName("div");
mapDiv_divs[2].style.right = "20px";
};
</script>
你把上面的代码删除,把
电脑砸坏!然后去找你老板,说我不干了!!!!