我的选项:
<!doctype html>
<html>
<head>
<title>Item Notifier v1.0.2</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="jquery.js"></script>
<script src="options.js"></script>
</head>
<body>
<h1>Cowboy's Item Notifyer</h1>
<label>Last updated hat:<h2 id='itemname'>[ loading... ]</h2></label>
</body>
</html>
然后我的options.js:
$(document).ready(function() {
$('#itemname').html() = localStorage.mostRecentHat;
});
它应该将innerHTML从[ loading... ]
更改为mostRecentHat
的值,但它会将值变为未定义且不会更改innerHTML。
答案 0 :(得分:3)
您应该将值作为参数传递给html
方法。
$(document).ready(function() {
$('#itemname').html(localStorage.mostRecentHat);
// document.getElementById('itemname').innerHTML = localStorage.mostRecentHat;
});