You have referenced the jQuery JS file haven't you? There's no reason why farzad's answer shouldn't work.
try this function $('div.total-title').text('test');
use as below:
<div id="getSessionStorage"></div>
For this to append anything use below code for reference:
$(document).ready(function () {
var storageVal = sessionStorage.getItem("UserName");
alert(storageVal);
$("#getSessionStorage").append(storageVal);
});
This will appear as below in html (assuming storageVal="Rishabh")
<div id="getSessionStorage">Rishabh</div>
When using the .html()
method, a htmlString
must be the parameter. (source) Put your string inside a HTML tag and it should work or use .text()
as suggested by farzad.
Example:
<div class="demo-container">
<div class="demo-box">Demonstration Box</div>
</div>
<script type="text/javascript">
$("div.demo-container").html( "<p>All new content. <em>You bet!</em></p>" );
</script>
Source: Stackoverflow.com