DEV Community

Faisal Ahmed
Faisal Ahmed

Posted on

Javascript Document Object Methods

use of createElement,innerHTML,appendChild


function book(){

    const newRow=document.createElement('tr');


    const newTitle=document.createElement('td');
    newTitle.innerHTML=title.value;
    newRow.appendChild(newTitle);


    bookList.appendChild(newRow);


}

Enter fullscreen mode Exit fullscreen mode

use of textContent,value

//message is a span tag/paragraph tag
//weightCalculate/heightCalculate is a input tag

function calculateBMI(){
    let height,weight,bmi;
    weight=Number(weightCalculate.value);
    height=Number(heightCalculate.value);
    bmi=weight/(height*0.0254*height*0.0254);
    output.textContent=bmi.toFixed(2);
    let report= showMessage(bmi);
    message.textContent=report;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)