CheckBox
CheckBox selection and Cancellation methods in JavaScript and jquery
Javascript:
document.getElementById ("MyCheck"). Checked=true
document.getElementById ("MyCheck"). Checked=false
Jquery:
$ ("#myCheck"). attr ("Checked", "checked");
$ ("#myCheck"). Removeattr ("checked");//Cancel Select all
Select
select gets the option value in JavaScript and jquery
Javascript:
var Mylist=document.getelementbyid ("MyList");
Get ID Mylist.value
Gets the option value Mylist.options[mylist.selectedindex].text
Jquery:
Gets the ID $ ("#myList"). Val ()
Gets the option value $ ("#myList option:selected"). Text ()
select assignment in JavaScript and jquery
Javascript:
var Mylist=document.getelementbyid ("MyList");
Mylist.options[1].selected=true;
Jquery:
$ ("#myList"). Get (0). options[2].selected = true;
Original Address http://haiqiancun.com/bbs/bbsPage/0/detail/297e9e7946a599780146a5a38dde0003/1/20140623141930
The differences between the "checkbox" and "Select" Objects in JavaScript and jquery are sorted