checkbox

checkbox在javascript和jquery中选中和取消的方法

Javascript:

document.getElementById("myCheck").checked=true

document.getElementById("myCheck").checked=false

Jquery:

$("#myCheck").attr("checked","checked");

$("#myCheck").removeAttr("checked");//取消全选

select

select在javascript和jquery中获取option值

Javascript:

var mylist=document.getElementById("myList");

获取id mylist.value

获取选项值mylist.options[mylist.selectedIndex].text

Jquery:

获取id $("#myList").val()

获取选项值 $("#myList option:selected").text()

select在javascript和jquery中赋值

Javascript:

var mylist=document.getElementById("myList");

mylist.options[1].selected=true;

Jquery:

$("#myList").get(0).options[2].selected = true;

原文地址http://haiqiancun.com/bbs/bbsPage/0/detail/297e9e7946a599780146a5a38dde0003/1/20140623141930

05-08 08:04