开发者

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 jq开发者_C百科uery 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. Try console.log $('body').parent().html()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜