jquery - Taking Values of a Form and Using Them for Comparison in Javascript -
i'm attempting create html-based game. game supposed use or tag accept data user. i'd assign data entered variable in javascript comparison. comparison used alter page, bringing next part of game view. how assign value of input user types javascript variable comparison?
i thought along lines of:
function(){ document.getelementbyid("submit"); }
would work situation, i'm not sure.
the code have rather simple, can see here: fiddle
i'm pretty new js/jquery, forgive me if question incredibly easy answer!
there many ways this.
it seems way going using button "read input now".
in case, can add event handler button read in there.
see following:
<h3>you've entered dungeon. want continue or exit?</h3> <div id="actioninterface"> <input type="text" id="myinput" value="user"/> <button id="clickme">enter option</button> </div> <script> var myvar; $("#clickme").click(function(){ myvar = $("#myinput").val(); alert(myvar); }); </script>
Comments
Post a Comment