function - reload only elements of the certain class on click - jquery -
i have function reloads page on click:
$('#reload').click(function () { location.reload(); });
what should put instead of location.reload();
in order reload elements aaa class?
tried $('.aaa').reload();
- doesn't work.
you can use .load load contents element, i.e provided have url returns html loaded element. cannot reload element old state because html stateless unless manage state manually.
$('#reload').click(function () { $('.aaa').load(url); //url returns content of html. });
or other way storing previous state of element in localstorage/cookie/data cache etc , populate on click.
an example second way is:
$('#reload').click(function () { $('.aaa').replacewith($('.aaa').data('cache')); //just replace 1 in data cache }); $('.aaa').data('cache', $('.aaa').clone(true)); //on load of page save current element in data cache, later use
Comments
Post a Comment