Document.write issues

前端 未结 3 500
借酒劲吻你
借酒劲吻你 2021-01-24 05:27

I am making a page where users can answer questions (using radio buttons) about a product they are selling back. When they hit a button at the bottom of the page, a price quote

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-24 06:08

    There is no issue with document.write, it is doing exactly what it is supposed to do:

    Overwrite the page with the new content.

    If you do not want to do that, then you have to give it some context to write to.

    For example:

    function getQuote(){
        var textArea = document.getElementById('textArea');
        textArea.innerHTML = "Your Quote Is: $", price, ".00";
    }
    

    Which puts whatever your text is into a DOM element with id="textArea"

提交回复
热议问题