mikemaccana
mikemaccana

Reputation: 123450

Manipulating an existing document using node jquery

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?

Upvotes: 1

Views: 104

Answers (1)

Daniel Baulig
Daniel Baulig

Reputation: 10999

console.log $('body').html() will output the innerHTML of your body tag, which propably only is the newly created div. Try console.log $('body').parent().html()

Upvotes: 1

Related Questions