Examples of values and assignments to basic controls in Jquery
- 2020-03-30 03:03:33
- OfStack
TEXTBOX.
Var STR = $(" # TXT "). Val ();
$(" # TXT "). Val (Value);
// text box, text area:
$(" # text_id "). Attr (" value ", "); // empty the content
$(" # text_id "). Attr (" value ", "test"); // fill in the content
LABLE:
Var STR = $(" # LBL "). The text ();
$(" # LBL "). The text (Value);
Var valradio = $(" input [@ type = radio] [@ checked] "). The val ();
Var item = $(' input [@ name = items] [@ checked] '). The val ();
Var checkboxval = $(" # checkbox_id "). Attr (" value ");
Var selectval = $(' # select_id). Val ();
// checkbox:
$(" # chk_id "). Attr (" checked ", "); // uncheck it
$(" # chk_id "). Attr (" checked ", true); / / check
If ($("#chk_id").attr('checked')==true)//
Radio group:
$(" input [@ type = radio] "). The attr (" checked ", '2'); // the item with value=2 is the currently selected item
// drop-down select:
$(" # select_id "). Attr (" value ", "test"); // the item that sets value=test is the currently selected item
$("testtest2").appendto ("#select_id")// add options to the drop-down box
$(" # select_id "). The empty (); // empty the drop-down box
Gets the values of a set of selected items of the radio named (items)
Var item = $(' input [@ name = items] [@ checked] '). The val (); // val() = undefined if not selected
Gets the text of the selected item in the select
Var item = $(" select [@ name = items] option [@ selected] "). The text ();
The second element of the select drop-down box is the currently selected value
$(' # select_id) [0]. SelectedIndex = 1;
The second element of the radio radio group is the currently selected value
$(' input [@ name = items] '). The get (1) checked = true;
// reset the form
$(" form "). Each (function () {
The reset ();
});
Here is the path to set img
$(" # img1 "). Attr (" SRC ", "Imges/test. JPG");
Var STR = $(" # TXT "). Val ();
$(" # TXT "). Val (Value);
// text box, text area:
$(" # text_id "). Attr (" value ", "); // empty the content
$(" # text_id "). Attr (" value ", "test"); // fill in the content
LABLE:
Var STR = $(" # LBL "). The text ();
$(" # LBL "). The text (Value);
Var valradio = $(" input [@ type = radio] [@ checked] "). The val ();
Var item = $(' input [@ name = items] [@ checked] '). The val ();
Var checkboxval = $(" # checkbox_id "). Attr (" value ");
Var selectval = $(' # select_id). Val ();
// checkbox:
$(" # chk_id "). Attr (" checked ", "); // uncheck it
$(" # chk_id "). Attr (" checked ", true); / / check
If ($("#chk_id").attr('checked')==true)//
Radio group:
$(" input [@ type = radio] "). The attr (" checked ", '2'); // the item with value=2 is the currently selected item
// drop-down select:
$(" # select_id "). Attr (" value ", "test"); // the item that sets value=test is the currently selected item
$("testtest2").appendto ("#select_id")// add options to the drop-down box
$(" # select_id "). The empty (); // empty the drop-down box
Gets the values of a set of selected items of the radio named (items)
Var item = $(' input [@ name = items] [@ checked] '). The val (); // val() = undefined if not selected
Gets the text of the selected item in the select
Var item = $(" select [@ name = items] option [@ selected] "). The text ();
The second element of the select drop-down box is the currently selected value
$(' # select_id) [0]. SelectedIndex = 1;
The second element of the radio radio group is the currently selected value
$(' input [@ name = items] '). The get (1) checked = true;
// reset the form
$(" form "). Each (function () {
The reset ();
});
Here is the path to set img
$(" # img1 "). Attr (" SRC ", "Imges/test. JPG");