I think the question is trival, however i can not find the solution. Im trying to refresh div automatically, for instance:
<div id="divToRefresh"> @(DateTime.Now)</div>
How can I do this in JQuery?
I think the question is trival, however i can not find the solution. Im trying to refresh div automatically, for instance:
<div id="divToRefresh"> @(DateTime.Now)</div>
How can I do this in JQuery?
You cant refresh the div as you suggest. You need to load new content in, for your example this will work
$('#divToRefresh').html(now.format("dd/m/yy h:MM tt"))
The above method uses pure JavaScript. If you want to use .Net you can use JavaScript to launch a AJAX call to a JSON Action Reuslt.
public JsonResult GetDate()
{
return Json(new { CurDate = DateTime.Now}, JsonRequestBehavior.AllowGet);
}
And your JQuery
$.getJSON('pathToActionResult', function(data) {
$('#divToRefresh').html(data.CurDate)
});