当前位置: 代码迷 >> Web前端 >> JQuery小结之表单操作(select , div , checkbox 操作)
  详细解决方案

JQuery小结之表单操作(select , div , checkbox 操作)

热度:352   发布时间:2012-10-06 17:34:01.0
JQuery总结之表单操作(select , div , checkbox 操作)

?

// JavaScript Document?

//1.表单元素的获取

//获取所有input元素

$(":input")

?

//获取所有checkbox元素?

$(":checkbox")?

?

//获取id为age的元素

$("#age").val();

?

//获取name为age的元素

$("input[name='age']").val();

?

//获取name为age的select元素

$("select[name='age']");?

?

//获取name为remark的textaret元素

$("textarea[name='remark']");

?

//获取checkbox是否选中.

$("input[name='commandType']").attr("checked") ;?

?

//循环获取checkbox选择的值

$("input[name='project.builtProduct']").each(function(i){

if($(this).attr("checked")){

product++;

}

});

?

?

//获取select选中的项目

$("select[name='project.solution'").find("option:selected").text()

?

//设置第一项选中

$("select[name=modelId]")[0].selectedIndex=0;

/******

*

* 查找子元素

*/

//1.在div中查找input,table元素

$("#divId").find("input")

$("#divId").children("table")

?

//2.查找某个元素的父元素并添加样式

$("#id").parent().addClass('inpCheckOn')


?

  相关解决方案