자바스크립트 문서 객체 메소드

3428 단어 javascriptdom
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);


}




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;
}

좋은 웹페이지 즐겨찾기