php - How to set value on page load using javascript? -
i have set dynamically text value when page load. code is..
$(document).ready(function() { //function call setname(); }); function setname() { document.getelementbyid('loginname').value = localstorage.getitem("username"); }
<span class="text-muted text-xs block" id="loginname"></span>
i value local session why not set on loginname
field? don't know why, please me.
span
elements not have value
property - need set innertext
:
function setname() { document.getelementbyid('loginname').innertext = localstorage.getitem("username"); }
alternatively, can use jquery exclusively:
$(function() { $('#loginname').text(localstorage.getitem('username')); });
Comments
Post a Comment