Internet‎ > ‎HTML‎ > ‎

Examples

1. Adding HTML button using JavaScript at specified position and with specific caption:

function addButton(name,w,h,text)
{
    var div1 = document.createElement('div') ;
    div1.setAttribute('id',name + 'Div') ;
    div1.setAttribute('style','position: absolute; top:' + w + 'px; left: ' + h + 'px') ;

    var btn = document.createElement('input') ;
    btn.setAttribute('type','button') ;
    btn.setAttribute('id',name) ;
    btn.setAttribute('value',text) ;

    div1.appendChild(btn) ;
    document.body.appendChild(div1) ;
}
Comments