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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -