How to convert Document.write to Jquery function

I have tried to convert document.write into jquery latest function but not working

here is code document.write(html.join(""));

when i convert this javascript line into jquery like this $(body).append(html.join(""));

then chrome dev tools give an error

Uncaught ReferenceError: $ is not defined

Please Help me

58 thoughts on “How to convert Document.write to Jquery function”

  1. Your error may be a result of the page potentially not loading jQuery at all or your above script is executing before jQuery is called or is ready. Adding in a DOMContentLoaded listener would be my first fix:

    document.addEventListener('DOMContentLoaded', function() {

    Though you may need to call the heavier handed window.onload listener instead depending on your jQuery script host: window.onload=function(){ $(body).append(html.join("")); }


Leave a Comment