1. Simple button js events are used to determine and display prompts
Copy codeThe Code is as follows:
<Script type = "text/javascript" language = "javascript">
$ (Document). ready (function (){
$ ("# Btnlogin"). click (function (){
$ ("# LblInfo" ).html ("");
Var uid = $. trim ($ ("# txtUsername"). val ());
Var pwd = $. trim ($ ("# txtPassword"). val ());
If (uid = ""){
$ ("# LblInfo" ).html ("the account cannot be blank ");
$ ("# TxtUsername"). focus ();
Return false;
}
If (pwd = ""){
$ ("# LblInfo" ).html ("the password cannot be blank ");
$ ("# TxtPassword"). focus ();
Return false;
}
});
});
</Script>
2. process the drop-down list
Copy codeThe Code is as follows:
Function dropTypeChange ()
{
Var sel = $ ("# <% = dropType. ClientID %> option: selected"). val ();
If (sel = "-1 ")
{
$ ("# <% = TxtNo. ClientID %>"). attr ('Disabled ', true );
}
Else
{
$ ("# <% = TxtNo. ClientID %>"). attr ('Disabled ', false );
}
}
// Obtain the value of the first option
$ ('# Test option: first'). val ();
// The value of the last option
$ ('# Test option: last'). val ();
// Obtain the value of the second option
$ ('# Test option: eq (1)'). val ();
// Obtain the selected value
$ ('# Test'). val ();
$ ('# Test option: selected'). val ();
// Option with the value of 2 is selected
$ ('# Test'). attr ('value', '2 ');
// Set the first option to selected
$ ('# Test option: last'). attr ('selected', 'selected ');
$ ("# Test"). attr ('value', $ ('# test option: la'). val ());
$ ("# Test "). attr ('value', $ ('# test option '). eq ($ ('# test option '). length-1 ). val ());
// Obtain the select Length
$ ('# Test option'). length;
// Add an option
$ ("# Test"). append ("<option value = '9'> ff </option> ");
$ ("<Option value = '9'> ff </option>"). appendTo ("# test ");
// Add the selected item
$ ('# Test option: selected'). remove ();
// Select a specified item
$ ('# Test option: first'). remove ();
// The specified value is deleted.
$ ('# Test option'). each (function (){
If ($ (this). val () = '5 '){
$ (This). remove ();
}
});
$ ('# Test option [value = 5]'). remove ();
// Obtain the label of the first Group
$ ('# Test optgroup: eq (0)'). attr ('label ');
// Obtain the value of the first option in the second group
$ ('# Test optgroup: eq (1): option: eq (0)'). val ();