jQuery equivalent for window.[removed]

前端 未结 3 581
南笙
南笙 2021-01-04 08:37

Does anyone know the jQuery equivalent for window.document.write(\'\') in javascript? Thanks

相关标签:
3条回答
  • 2021-01-04 08:51

    This will add the string "hello" right before the body closing tag. Not exactly the behavior of write, but you can do this to any element to get the content to appear where you want it.

    $(document.body).append('hello');
    

    Also available are prepend(content) and replaceWith(content) for all your insertion needs!

    0 讨论(0)
  • 2021-01-04 09:00

    Try to use this example:

    table = $('#flightTypeEditTemplate').clone();
    table.attr('id','');
    document.write(table.html());`
    
    0 讨论(0)
  • 2021-01-04 09:01

    First, jQuery is JavaScript, it is just a library of functions to make coding easier.

    Second, you should avoid the use of document.write. You should use jQuery to append the text to the DOM element you want.

    Example:

    $('#myDiv').append('some new text')
    
    0 讨论(0)
提交回复
热议问题