Question:

In jQuery, how do I do DOM navigation on a string?

by  |  earlier

0 LIKES UnLike

I'm in the callback function of a jQuery get, and so have the html of the page I got as a string variable. How can I create a page object from that html so that I can perform jQuery traversing functions on it, it pull bits out?

 Tags:

   Report

1 ANSWERS


  1. You should be able to add it to an element already on your page like this:

    var cont = document.getElementById('container');

    cont.innerHTML = yourString;

    The elements will automatically be added to the DOM once they're processed and added to the container, you should then be able to reference the new elements through JS.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.