2013-03-31 24 views
-1

我options.html:

<!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。

回答

3

你应该传递值作为参数传递给html方法。

$(document).ready(function() { 
    $('#itemname').html(localStorage.mostRecentHat); 
    // document.getElementById('itemname').innerHTML = localStorage.mostRecentHat; 
});