开发者

Prototype: wrapping raw HTML to create extended element

I am reading in a complex chunk of HTML and I'd love to be able to walk this sub-tree of HTM开发者_如何学PythonL in the same way I can the DOM.

Is there a way in Prototype to take a raw chunk of HTML (say from an AJAX call) and 'wrap it' in some way so that it becomes a Prototype element and thus allow me to search it using .up() .down() etc?

Or do I need to add it to the DOM first before I can manipulate it in this way?

Thanks in advance.


var myDOMStructure = (new Element('div')).update(yourHTML);
myDOMStructure.down().down().up(); /// etc...


You could create a container element, give it an ID and put your complex HTML in it:

$('mydiv').update(complexHTML);

then you should be able to work through it like a DOM element.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜