Is there a way to have a simple refresh of an element?
I'm trying to refresh an element in my page upon a click of a button. Basically, I just need a div to just pull the same HTML it pulled when I first came to the page. Nothing with Ajax callbacks.
How can I do this?
$('#button').live('click',function(开发者_开发知识库) {
//refresh #div
});
well on load you can do:
$('div').each(function(){
$(this).data('orig_html',this.innerHTML);
})
and then in ur refresh:
$('#button').live('click',function() {
$('div').each(function(){
$(this).html($(this).data('orig_html'));
})
});
here is the manual on jQuery data()
fiddle showing you is here: http://jsfiddle.net/maniator/wSqnM/
$('#button').click( function(){
$("#yourDiv").load("page_url");
});
Check out the documentation http://api.jquery.com/load/ about the load function.
I think this is simpler and what you might be looking for.
Hope that helps
精彩评论