[英]How can I change the width and height of parent div using js when we only have the id of the child
How can I change the width and height of parent div using js when we only have the id of the child 当我们只有孩子的ID时,如何使用js更改父div的宽度和高度
<li>
<span id="head-ing"><?=$row['subject']?></span>
<script>
/*what js to use*/
</script>
</li>
The div comes from the Database. div来自数据库。 so i cannot modify that 所以我不能修改
使用parentElement
:
document.getElementById("myLI").parentElement.style.width = "200px";
var child = document.getElementById("childId");
parent = child.parentNode;
parent.style.width= "100px";
parent.style.height= "100px";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.