1. Radio button
<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML><Head> <title>Js24.html</title> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"> <Scripttype= "Text/javascript"src= "Jquery/jquery-3.2.1.min.js"></Script> <Scripttype= "Text/javascript"src= "Test.js"></Script></Head><Body><Div> <inputtype= "Radio"name= "Sex"value= "M"checked>Man<BR> <inputtype= "Radio"name= "Sex"value= "F">Woman<BR></Div><inputtype= "button"value= "click me"onclick= "invoice.test ();"></Body></HTML>
Test.js
;(function(window, document, undefined) {var Invoice =function () { // defines a property that an object receives a page passed over var New Object (); // the value taken is either male or female, but M or F, which I understand is the value of the property of value Params.sex = $ ("Input[name= ' Sex ']:checked"). Val (); Alert ("Gender:" += Invoice;}) (window, document);
2. Drop-down list
<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML><Head> <title>Js24.html</title> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"> <Scripttype= "Text/javascript"src= "Jquery/jquery-3.2.1.min.js"></Script> <Scripttype= "Text/javascript"src= "Test.js"></Script></Head><Body><Div> <SelectID= "Cartype"> <optionvalue= "Volvo">Volvo</option> <optionvalue= "Saab">Saab</option> <optionvalue= "Opel">Opel</option> <optionvalue= "Audi">Audi</option> </Select></Div><inputtype= "button"value= "click me"onclick= "invoice.test ();"></Body></HTML>
Test.js
;(function(window, document, undefined) {var Invoice =function () { var New Object (); = $ ("#carType"). Val (); Alert ("model:" += Invoice;}) (window, document);
Common jquery Examples