Reputation: 417
i have page register here and i wanna use LocalStorage to show email verifiaction after register. but i still confuse with method after click and before click.
i have notification here
<div class="alert success">
and i have input button here
<input type="submit" class="btn btn-default size-new-account" value="<?php esc_attr_e( 'Create new account', 'woocommerce' ); ?>" />
i set a localstorage on script like
localStorage.setItem('register1','.alert.success');
jQuery('input.btn.btn-default.size-new-account').click(function(){
var reg = localStorage.getItem('register1');
});
but it wont works. the div notification i set display: none; in .css
Upvotes: 1
Views: 2137
Reputation: 19154
LocalStorage
not for showing or hiding element, it store string, use .show()
, .hide()
instead
localStorage.setItem('register1', 'Im string from localStorage');
jQuery('input.btn.btn-default.size-new-account').click(function() {
var reg = localStorage.getItem('register1');
$('.alert.success').html(reg);
$('.alert.success').show();
});
.alert.success {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="alert success">I'm hidden</div>
<input type="submit" class="btn btn-default size-new-account" value="submit" />
Upvotes: 2