: Enable to obtain the elements in the input state
: Disabled: gets elements that cannot be entered.
: Checked: Get the selected form Element
: Seleced: Obtain the selected element from the drop-down list.
The following is an example.
Html
Copy codeThe Code is as follows:
<Body>
<Form id = "form1" runat = "server">
<Div>
<Ul>
<Li> <label> Order Number: </label> <input type = "text" disabled = "disabled"/> </li>
<Li> <label> order owner: </label> <input type = "text"/> </li>
<Li>
<Input type = "checkbox" name = "ca" value = "red"/> Red
<Input type = "checkbox" name = "ca" value = "yellow"/> yellow
<Input type = "checkbox" name = "ca" value = "blue"/> blue
<Input type = "checkbox" name = "ca" value = "green"/> green
</Li>
<Li>
<Select multiple = "multiple">
<Option> select 1 </option>
<Option> select 2 </option>
<Option> select 3 </option>
<Option> select 4 </option>
</Select>
</Li>
</Ul>
</Div>
</Form> <div id = "msg">
<P id = "cc"> </p>
<P id = "option"> </p> </div>
</Body>
JavaScript code:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
JQuery (function (){
$ ("Input: text: disabled"). val ("cannot input ");
$ ("Input: text: enabled"). val ("can be entered ");
(
Function checkboxclick (){
$ (": Checkbox"). unbind ("click", checkboxclick );
Var vv = '';
$ (": Checkbox: checked"). each (function (){
Vv + = $ (this). val () + ",";
});
$ ("# Cc" ).html ("selected data:" + vv );
$ (": Checkbox"). click (checkboxclick );
}
)()
$ ("Select"). change (function (){
Var tt = '';
$ ("Select option: selected"). each (function (){
Tt + = $ (this). text () + ",";
});
$ ("# Option" pai.html ("the selected project is:" + tt );
}). Trigger ("change ");
});
</Script>
Note the following points:
1 Previously we mentioned that bind is used to bind events, so the unbind here cancels the event.
2. trigger () method triggers the specified event type of the selected element.
3 when adding a function in jQuery (function () {, brackets should be added to the outside, and parentheses should be added to the end, as shown below:
JQuery (function (){
(
Function check ()
{
})()
})
4. Select the check box in the Implementation Layer and assign it to other element values.
Html
Copy codeThe Code is as follows:
<Form id = "form1" runat = "server">
<Div>
<Input type = "button" id = "btn1" value = "pop-up"/>
<Input type = "checkbox" name = "ca" value = "red"/> Red
<Input type = "checkbox" name = "ca" value = "yellow"/> yellow
<Input type = "checkbox" name = "ca" value = "blue"/> blue
<Input type = "checkbox" name = "ca" value = "green"/> green
<Input type = "checkbox" name = "ca" value = "white"/> White
<Input type = "checkbox" name = "ca" value = ""/> black
</Div>
<Div id = "cc"> </div>
</Form>
Javascript
Copy codeThe Code is as follows:
JQuery (function (){
(
Function checkboxclick (){
$ (": Checkbox"). unbind ("click", checkboxclick );
Var vv = '';
$ (": Checkbox: checked"). each (function (){
Vv + = $ (this). val () + ",";
})
$ ("# Cc" ).html ("selected data:" + vv );
$ (": Checkbox"). click (checkboxclick );
})()
})
As follows: