Is there a way to allow [removed] after document.ready?

后端 未结 1 1969
孤城傲影
孤城傲影 2021-01-28 17:35

I tried to redefine the document.ready function to capture what should have been written after document.ready

$(document).ready(function(){
 docume         


        
相关标签:
1条回答
  • 2021-01-28 18:13

    You don't need to use document.write in this situation. You use a jquery selector and the .html() method (or .append() or similar) to place content inside an element.

    For example, if you had a div with the class container

    var content = '<p>Some content</p>';
    $('div.container').html(content);
    

    this code would replace the contents of the container with the value of content. You'll notice that CSS style selectors are used for selecting elements, so to select the entire body you can use

    $('body')
    

    or for all text inputs, you can use

    $('input[type="text"]')
    

    .html() will replace the entire innner content, and .append() will add to the element after the other content.

    0 讨论(0)
提交回复
热议问题