I want to do simple calculations using js and jquery. Regarding the values in the fields, the alert box should be calculated. Here's my code:
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; P id = "demo" & gt; & Lt; / P & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("# btn1"). Click (function () {alert ("resolution:" + $ ("# demo"). Val ());})}} ; Function myFunction (A, B) {var a; Var B; Return * b;} Document.getElementById ("Demo"). InnerHTML = myFunction (A, B); button ID = " BTN1 "& gt; Results & lt; / Button & gt; & gt; & gt; & lt; / html>
here:
& lt; script & gt; $ ( Document) .ready (function Value () {// gab value $ ('# demo'). Val (myFunction ($ ('# a'). Val (), $ ('# b'). Val ()); $ ("# btn 1 ") (function () (warning (" solution: "+ $ (" # demo "). Val ());});}); function myFunction (A, B) {return A * B;} & Lt; / script> & lt; input id = "a" type = "text" value = "10" /> & lt; input id = "b" type = "text" value = "5" /> & Lt; Button ID = "BTN1" & gt; Results & lt; / Button & gt;
No comments:
Post a Comment