Is there a clean way to parse HTML?

What is the way to replace HTML using jquery without loading original HTML?

  • I am loading HTML content from the third party server using JSONP & using jQuery.html("html") function to replace full HTML. I have used this code in head tag but when I am trying to access that site, it loads the default HTML first & then replace the HTML using jQuery. Is there any way to make the jQuery loaded HTML to be displayed first? Any help would be appreciated. Thanks.

  • Answer:

    You could wrap your original content in one hidden div (display: none; in CSS), and dump your loaded content into another one which is visible. Then you can show/hide/toggle either divs easily using jQuery. BTW since your remote content may take a while to load, it's good to have a loading indicator at page load, too.

Tuan-Anh Fan at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.