I have one div id=userinfo
<html>
<head></head>
<body>
<div id=userinfo></div>
</body>
</html>
And now I want to append something into this div, depending on the localStorage.
if (localStorage==0){$("#userinfo").append("<p>Test</p>");} else {$("#userinfo").append("<p>Hello</p>");}
But it failed, no matter I input this script into separate JS file or add them into the head of the html file. I tried exclude this with Google chrome developer tool's console, it works as expected.
I've tried another way round change the script into:
if (localStorage==0){alert("Test");} else {alert("Hello");}
And add this into JS file, it works!
So, now I'm stacked why my jQuery code not work?