将HTML内容加载到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 contains lots of divs in it and i want to get particular div from the loaded content. Here is my code $("#contentdiv").load("message.html #divname");

can u tell me how to get rid from this

Thanks in advance

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')); 
                    }
};

try this:

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

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