Im trying something simple below. I want to accept user input for their name click a button save it and when the app loads a second time it displays the name.
Où est-ce que je me trompe ci-dessous ?
Do i need to put this code block somewhere else?
$(function(){
$('#saveButton').click(function() {
window.localStorage.setItem("name", $('#name').val());
});
$('#newpage').live('pageshow', function() {
var personName = window.localStorage.getItem("name");
if(personName.length>0){
$('#name').val(personName);
}
});
});
Fichier html complet
$(function(){
$('#saveButton').click(function() {
window.localStorage.setItem("name", $('#name').val());
});
$('#newpage').live('pageshow', function() {
var personName = window.localStorage.getItem("name");
if(personName.length>0){
$('#name').val(personName);
}
});
});
Hello World
Page d'accueil
hello Phone Gap and JQuery Mobile! nouvelle page
pied de page
nouvelle page
what is your name?
Sauvegarder
pied de page
app.initialize();