document.getElementById

指定したIDの要素を取得

element = document.getElementById(id);

<style>
    #geteleid_div01    {
        border:1px solid;
        width:100px;
        margin-bottom:10px;
        padding:10px;
    }
</style>

<script>
    function func_geteleid(chawide)    {
        ele=document.getElementById('geteleid_div01');
        ele.style.width = chawide;
    }
</script>

<div class="geteleid01">
    <div id="geteleid_div01">要素1</div>
    <button onclick="func_geteleid('300px');">幅を広げる</button>
    <button onclick="func_geteleid('100px');">幅を戻す</button>
</div>

See the Pen PPPMMQ by nosigcode (@nosig) on CodePen.

tagTimeLog Lite

Simple time tracking tool
Developed by Namu Works