I’m using node-jquery, and I’d like to use it to modify an existing document – which is all the way from the doctype to closing html tag.
But I’m finding node jquery a little off –
$ = require 'jquery'
$('body').append "<div class='testing'>Hello World</div>"
console.log $("body").html()
Returns:
<div class="testing">Hello World</div>
Note the lack of a body tag, which in normal jquery would have been required. It’s like there’s a blank document – which I’m fine with, except appending a full document makes makes jquery crash.
How can $(“body”).append() work in a document that has no body? Is anyone else using node-jquery? Is it considered stable? How can I use it to manipulate an existing document?
console.log $('body').html()will output the innerHTML of your body tag, which propably only is the newly created div. Tryconsole.log $('body').parent().html()