javascript - Hashchange event -
so, there wrong hashchange... wont trigger
$('form').submit(function() { var form_data = ($(this).serialize()); window.location.hash = form_data.replace('=','/'); return false; }); $(window).on('hashchange', function () { var values = window.location.hash.slice(1).split('/'); $("[name=" + values[0] + "]").val(values[1]); }
you missing closing ); @ end of second event handler assigment.
$(window).on('hashchange', function () { '...'; }); //<= here had } other that, seems work fine. unless using ie7 of course, not support onhashchange (browser support).
Comments
Post a Comment