Skip to content Skip to sidebar Skip to footer

Loading Html Content Into Div

I am trying to load a HTML file into a DIV and access that whenever i need. This should be done once when loading the script and i can access this no.of time in my code. The HTML

Solution 1:

Load the page, when loaded, get the div you want, and insert it into your contentdiv.

$.ajax({ url: 'message.html', 
         success : function(data) { 
                       $('#contentdiv').html($(data).find('#divname')); 
                    }
};

Solution 2:

try this:

$("#contentdiv").html($(message.html).find("#divname"));

Solution 3:

From your question I understood that u want to select a particular div from the response html which will be loaded on #contentdiv.

Its better to access $('#contentdiv->ur div name').html(); or $('#contentdic .div').html() . here .div is a css class

Post a Comment for "Loading Html Content Into Div"