javascript - Code works on JS fiddle but not on my website -



javascript - Code works on JS fiddle but not on my website -

i trying create search history log using local storage in html , trying understand how utilize local storage function. have run odd problem.

this illustration works great: http://jsfiddle.net/hr3xq/17/

but when seek set on server nil happens when seek run code

<!doctype html> <html lang="en"> <head> <title>test</title> <meta charset="utf-8> <link rel="stylesheet" type="text/css" href="test.css"> <script type='text/javascript'> $(function () { $("#submit").click(function () { var name = $("#name").val(); localstorage.setitem('username',name); alert(localstorage.getitem('username')); }); }); </script> </head> <body> name: <input type="text" id="name"> <br/> <br/> <input type="button" id="submit" value="store in local"> </body> </html>

what doing wrong? i'm not used web-programming.

you'll need include jquery if want utilize jquery.

in jsfiddle, nice little toggle allows select frameworks/libraries you'd include.

however, when move code, jquery inclusion doesn't come along you. need either download or include via script tag in head (do above other script jquery loads before seek utilize it:

<script src="//code.jquery.com/jquery-latest.min.js"></script>

this mutual problem: whenever nothing happens, it's thought check browser's console. not including jquery, you'll this:

referenceerror: $ not defined

javascript html local-storage jsfiddle

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -