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.
精彩评论