Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

My page has multiple containers along with some elements. I performed drag and drop operations on the container elements. Initially i stored the element sequence structure and later after all drag operations before leaving the page i was storing sequence of the elements in the page. Now i need to compare current structure with existing structure. Before that i need to store html page into dom so that i can able to perform operations and replace the actual page.

If i am directly dumping html content to some element through innerHTML or html(). In those scenarios i was facing same id issues..

if i have dom object i can access like domObject.documentElementById()

can any one help me to fix the issue.. Thanks in advance

share|improve this question

put on hold as unclear what you're asking by MainMa, GlenH7, MichaelT, gnat, Bart van Ingen Schenau 3 hours ago

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

    
why didn't you ask at Stack Overflow? meta.stackexchange.com/a/129632/165773 –  gnat yesterday

2 Answers 2

In jQuery you can do something like:

// Loading body into dom

myhtml = $('body').html();               
$mh = $(myHtml);              


// Accessing and manipulating html in dom

$mh.find('h1');                       // Find all H1 from dom html.
$mh.find('h1').addClass('active');    // Add active class to all H1.

Hope this help you get through.

share|improve this answer

With javascript, document object should be available to you and then you can have body element with your document object. so you can get innerHtml of body content without any id issue

syntax might be something like document.body.innerHTML() for getting body inner HTML contents.

however for replace body content of page you can also use document.body.innerHTML = '<div>div inside body</div>' something like this.

but to do all these, first you need to make sure that you have DOM object available

More replace content reference: http://stackoverflow.com/questions/5558613/javascript-replace-text-in-the-html-body

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.