admin管理员组文章数量:1389762
How can I change the width and height of parent div using js when we only have the id of the child
<li>
<span id="head-ing"><?=$row['subject']?></span>
<script>
/*what js to use*/
</script>
</li>
The div es from the Database. so i cannot modify that
How can I change the width and height of parent div using js when we only have the id of the child
<li>
<span id="head-ing"><?=$row['subject']?></span>
<script>
/*what js to use*/
</script>
</li>
The div es from the Database. so i cannot modify that
Share Improve this question edited Apr 14, 2016 at 7:16 Pugazh 9,5615 gold badges36 silver badges56 bronze badges asked Apr 14, 2016 at 7:05 xYLOxxYLOx 311 silver badge2 bronze badges 4- I cannot use Inspect Element For that because the there is no ID of the div. – xYLOx Commented Apr 14, 2016 at 7:10
-
you want to change the
<li>
element ? – Asad Commented Apr 14, 2016 at 7:23 - No just the parent div element – xYLOx Commented Apr 14, 2016 at 12:14
-
i know it in jquery u can easily access parent by
$("#child").parent().css({'height':'200px'})
– Asad Commented Apr 14, 2016 at 12:22
2 Answers
Reset to default 4Use parentElement
:
document.getElementById("myLI").parentElement.style.width = "200px";
var child = document.getElementById("childId");
parent = child.parentNode;
parent.style.width= "100px";
parent.style.height= "100px";
本文标签:
版权声明:本文标题:javascript - How can I change the width and height of parent div using js when we only have the id of the child - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744678377a2619250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论